Hi I know this has been asked but it did not get an answer. I have a problem when I want to use a dll that is installed on C:\Program files (x86)\Dummu_API.dll
When I run my app it throws exception:
Could not load file or assembly 'Dummy_API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
My project have the reference as Copy Local = false and specific version = false. My project also is a x86 platform target.
I don´t know why my app don't find the assembly. Any Idea what it is happening?
Option 1
You can tell your application that you will resolve the Assemblies yourselves if not found in references. To do that:
In your applications main method attach assembly resolver:
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
Make sure you are not using the dynamically resolved assembly in your main method.
Your resolver method code (This is where you load an assembly - look at ResolveEventArgs I have just hard coded one but you can resolve various assemblies from different locations here)
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
return Assembly.LoadFile(@"C:\temp\ClassLibrary1.dll");
}
Option 2
Add this to your app.config (Only works for application base directory's sub folders)
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="PathToMyAssemblies\" />
</assemblyBinding>
</runtime>
So the file is not in the GAC, and there is not a local copy. You've eliminated the only two places it could be loading from - I don't know why you are expecting this to work.
You need to set Copy Local=true or install Dummy_API.dll into the Global Assembly Cache on the machine that will be running your code. One or the other.
来源:https://stackoverflow.com/questions/21894016/copy-local-false-file-not-found-exception-issue