I have a VS Add-In that's using a BinaryFormatter to deserialize an object. To resolve the type of this object, it's calling Assembly.Load(objectTypeFullName) but it's triggering an exception because Assembly.Load cannot find the assembly in any of the places it's searching on. The given assembly is sibling to the add-in assembly, but it seems that Assembly.Load() can't find it there.
A possible solution would be to determine where Assembly.Load should look for assemblies.
What should I do?
PS: I'm trying not to put this assembly on GAC because I would need to update it everytime I recompile the assembly.
For strong-named assemblies, the binding process continues by looking in the global assembly cache. The global assembly cache stores assemblies that can be used by several applications on a computer. All assemblies in the global assembly cache must have strong names.
Loads an assembly given its AssemblyName. The assembly is loaded into the domain of the caller using the supplied evidence. Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the application domain of the caller.
LoadFrom(String) Loads an assembly given its file name or path.
You can use AppDomainSetup.PrivateBinPath to add additional private search paths. This can be retrieved via AppDomain.SetupInformation.
Another option is to subscribe to AppDomain.AssemblyResolve in order to override the behavior when it fails to find your assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With