How to unload .dll using C #?

I am using a .dll link to my application. I want to unload a .dll into a button click event. How to do it???

+3
source share
3 answers

You cannot unload a separate assembly - you need to unload the whole AppDomain. In other words, you will need to load your other assembly (and related code) into a new one AppDomain, and then when you want to unload it, you will unload AppDomain.

Of course, this makes life a lot more difficult since you have to worry about routing calls between AppDomains, but that’s all .NET allows.

+8
source

, DLL, DLL AppDomain, AppDomain. .

, , , , AppDomain. .

AppDomain ( A), , AppDomain B, , . , , A, , B, , A, B, . , Serializable.

, MarshalByRefObject. AppDomain B AppDomain A, AppDomain. - , , COM.

B, A, B 5 , . MarshalByRefObject.InitializeLifetimeService().

+3
0

Source: https://habr.com/ru/post/1716755/


All Articles