[英]System.IO.FileNotFoundException: Could not load file or assembly. The system cannot find the file SharpSvn.dll
I'm trying to do a web page where you can browse through folders. 我正在尝试创建一个网页,您可以在其中浏览文件夹。 i have done this in separate solution and it all works, but when i tried to integrate it in solution with more then one project who are also referencing PostSharp I get this error:
我已经在单独的解决方案中做到了这一点,并且都可以正常工作,但是当我尝试将其与一个以上也引用PostSharp的项目集成到解决方案中时,出现此错误:
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].
It's possible that the SharpSVN
assembly is failing to load because it references a couple of native DLLs ( SharpSvn-DB44-20-win32.dll
and SharpSvn-Sasl21-23-win32.dll
for the 32-bit version). SharpSVN
程序集可能无法加载,因为它引用了两个本机DLL(32位版本的SharpSvn-DB44-20-win32.dll
和SharpSvn-Sasl21-23-win32.dll
)。 If those aren't somewhere in the system search path - which is generally the case for ASP.NET - then SharpSVN
will probably fail to load. 如果这些不在系统搜索路径中(通常是ASP.NET的情况),则
SharpSVN
可能无法加载。
I had a similar problem with one of my NuGet packages not working on MVC websites because the native DLLs were not loading. 我的一个NuGet程序包在MVC网站上无法正常工作时,我也遇到了类似的问题 ,因为未加载本机DLL。 Putting them in the
bin
folder of the website was not sufficient, because the bin
folder is neither on the search path nor is it the application folder. 将它们放在网站的
bin
文件夹中是不够的,因为bin
文件夹既不在搜索路径上,也不在应用程序文件夹中。
Try adding the following method to your application class in Global.asax.cs
file and call it from Application_Start()
: 尝试将以下方法添加到
Global.asax.cs
文件中的应用程序类,然后从Application_Start()
调用它:
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);
}
}
This will add your bin
folder to the system search path for your application only, which should allow SharpSvn
to locate the native DLLs it relies on. 这会将您的
bin
文件夹仅添加到您的应用程序的系统搜索路径,这将使SharpSvn
可以找到它依赖的本机DLL。 Just make sure that the files are actually there - you might have to copy them from the SharpSvn
distribution if they're not. 只需确保文件确实存在-如果没有,您可能必须从
SharpSvn
发行版中复制它们。
Of course I could be completely off the mark. 当然,我可能完全不合时宜。 Let me know either way.
无论哪种方式,请让我知道。
I wrote: "when i comment this method the error is gone: static void SVN_SSL_Override(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures; e.Save = true; } " 我写道:“当我评论此方法时,错误消失了:static void SVN_SSL_Override(对象发送者,SharpSvn.Security.SvnSslServerTrustEventArgs e){e.AcceptedFailures = e.Failures; e.Save = true;}“
don't know why but there was the problem so i removed: 不知道为什么,但是有问题,所以我删除了:
client.Authentication.Clear(); client.Authentication.Clear(); client.Authentication.SslServerTrustHandlers += new EventHandler(SVN_SSL_Override);
client.Authentication.SslServerTrustHandlers + =新的EventHandler(SVN_SSL_Override); client.Authentication.DefaultCredentials = new NetworkCredential(" ", " ");
client.Authentication.DefaultCredentials = new NetworkCredential(“ ”,“ ”);
and this method 和这种方法
static void SVN_SSL_Override(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures; 静态无效SVN_SSL_Override(对象发送方,SharpSvn.Security.SvnSslServerTrustEventArgs e){e.AcceptedFailures = e.Failures; e.Save = true;
e.Save = true; } "
}“
and just added: 并刚刚添加:
client.Authentication.UserNamePasswordHandlers += delegate(object obj, SharpSvn.Security.SvnUserNamePasswordEventArgs args) { args.UserName = " "; client.Authentication.UserNamePasswordHandlers + =委托(对象obj,SharpSvn.Security.SvnUserNamePasswordEventArgs args){args.UserName =“ ”; args.Password = " ";
args.Password =“ ”; args.Save = true;
args.Save = true; };
};
and now it works. 现在可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.