How to unload the .dll using c#?

后端 未结 3 506
梦如初夏
梦如初夏 2021-01-21 07:05

I am using .dll reference to my application. i want to unload the .dll in a button click event. How to do it ???

3条回答
  •  無奈伤痛
    2021-01-21 07:35

    You can't unload an individual assembly - you have to unload a whole AppDomain. In other words, you'll need to load your other assembly (and associated code) in a new AppDomain, then when you want to unload it you unload the AppDomain.

    Of course, this makes life a lot harder as you have to worry about marshalling calls between AppDomains - but it's all that .NET allows.

提交回复
热议问题