简体   繁体   中英

Deserialization - assembly not found issue c#

I am working on assembly project and external program is executed through the assembly program. System.Environment.CurrentDirectory assembly and Application.ExecutablePath paths are different due to external application. System.Environment.CurrentDirectory is Assembly path. Application.ExecutablePath External application path. While deserialization it throw expcetion

assembly not found

because "Application.ExecutablePath " not having my dlls . So i want to change use System.Environment.CurrentDirectory path for deserialization.

I recommend setting up an AssemblyResolve event on the current domain. That way you can explicitly determine where your DLLs are and load them if they're not found automatically.

Jeremy Tammik wrote about it here: http://thebuildingcoder.typepad.com/blog/2014/05/rvtva3c-assembly-resolver.html

The only thing to be careful of is that you should make sure the event is looking specifically for your DLLs (not any DLLs) - and that if it's not appropriate for you to load a DLL you return null (I occasionally run into scenarios where other people's addins don't implement this nicely, and it messes up my addin doing it).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM