首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >System.IO.FileNotFoundException:无法加载文件或程序集。系统找不到文件SharpSvn.dll

System.IO.FileNotFoundException:无法加载文件或程序集。系统找不到文件SharpSvn.dll
EN

Stack Overflow用户
提问于 2013-11-29 02:46:23
回答 2查看 4.5K关注 0票数 1

我正在做一个网页,你可以浏览文件夹。我已经在单独的解决方案中完成了这一点,并且所有的解决方案都能工作,但是当我试图将它与多个同时引用PostSharp的项目集成时,我得到了以下错误:

代码语言:javascript
运行
复制
 Unhandled exception (2.1.7.1, 32 bit, CLR 4.0, Release): System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\_projects\...\Libraries\SharpSvn\SharpSvn.dll' or one of its dependencies. The system cannot find the file specified.
    File name: 'file:///C:\_projects\...\Libraries\SharpSvn\SharpSvn.dll'

       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
       at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
       at PostSharp.Sdk.CodeModel.ModuleDeclaration.GetSystemModule()
       at PostSharp.Sdk.CodeModel.Domain.LoadAssembly(Assembly reflectionAssembly, Boolean lazyLoading)
       at PostSharp.Sdk.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)
       at PostSharp.Sdk.CodeModel.AssemblyRefDeclaration.GetAssemblyEnvelope()
       at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration _0)
       at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3()
       at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute()
       at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
       at PostSharp.Sdk.Extensibility.Project.Execute()
       at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
       at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value         [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-03 13:28:18

我写道:“当我注释这个方法时,错误就消失了:静态的void SVN_SSL_Override(对象发送方,SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures;e.Save = true;}

不知道为什么,但有问题,所以我删除了:

client.Authentication.Clear();client.Authentication.SslServerTrustHandlers += new EventHandler(SVN_SSL_Override);client.Authentication.DefaultCredentials =新NetworkCredential("","");

而这种方法

静态空SVN_SSL_Override(对象发送方,SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures;e.Save = true;}“

并补充说:

client.Authentication.UserNamePasswordHandlers +=委托(object obj,SharpSvn.Security.SvnUserNamePasswordEventArgs args) { args.UserName = "";args.Password = "";args.Save = true;};

现在起作用了。

票数 0
EN

Stack Overflow用户

发布于 2013-11-29 03:58:35

SharpSVN程序集可能无法加载,因为它引用了一些本地DLL(32位版本的SharpSvn-DB44-20-win32.dllSharpSvn-Sasl21-23-win32.dll )。如果这些内容不在系统搜索路径中--这通常是ASP.NET的情况--那么SharpSVN可能无法加载。

我有一个similar problem,其中一个NuGet包没有在MVC网站上工作,因为本地DLL没有加载。将它们放入网站的bin文件夹是不够的,因为bin文件夹既不在搜索路径上,也不是应用程序文件夹。

尝试将以下方法添加到Global.asax.cs文件中的应用程序类中,并从Application_Start()调用它

代码语言:javascript
运行
复制
public static void CheckAddBinPath()
{
    // find path to 'bin' folder
    var binPath = Path.Combine(new string[] { AppDomain.CurrentDomain.BaseDirectory, "bin" });
    // get current search path from environment
    var path = Environment.GetEnvironmentVariable("PATH") ?? "";

    // add 'bin' folder to search path if not already present
    if (!path.Split(Path.PathSeparator).Contains(binPath, StringComparer.CurrentCultureIgnoreCase))
    {
        path = string.Join(Path.PathSeparator.ToString(), new string[] { path, binPath });
        Environment.SetEnvironmentVariable("PATH", path);
    }
}

这将将您的bin文件夹添加到您的应用程序的系统搜索路径中,这将允许SharpSvn定位它所依赖的本机DLL。只需确保文件实际上在那里-如果它们不在,您可能必须从SharpSvn发行版中复制它们。

当然,我可能会完全偏离目标。不管怎样让我知道。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20277586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档