开发者

Remove all references to a DLL across all application domains

开发者 https://www.devze.com 2022-12-24 17:03 出处:网络
I have a web application that dynamically loads assemblies based on database configuration entries to perform certain actions (dynamic p开发者_开发问答lugin style architecture).

I have a web application that dynamically loads assemblies based on database configuration entries to perform certain actions (dynamic p开发者_开发问答lugin style architecture).

The calls to the objects are in a Factory Pattern implementation, and the object is cached (in a static dictionary<> within the Factory) as the calls can be made many thousands of times in a minute.

The calls to this factory are made from both the main web application and a number of webservices, some in different assemblies/projects.

When I need to update one of these DLLs, I have to recycle IIS to get the DLL released.

As this has an impact on another application on the server, I wanted to know if there was a way I could release the DLL without restarting IIS?


There's absolutely no way to unload a loaded assembly other than killing the AppDomain which is basically what you are doing when you restart IIS.


You can try restarting the application pool not the whole IIS server. Maybe that will do the trick for you


If you have an assembly that you need to load and unload you will have to jump through a few hoops.

  • the types being loaded must derive from MarshalByRefObject
  • the types being loaded must derive from an interface that will be used to call them
  • you must build a remoting based 'loader' to isolate the loaded assembly in a new appdomain, which can be unloaded.

see http://www.west-wind.com/presentations/dynamicCode/DynamicCode.htm for a good introduction. It is a bit dated and deals with dynamically generated code but given your rep I would assume that you can extract the relevant information.

0

精彩评论

暂无评论...
验证码 换一张
取 消