问题
Is it a good idea to replace an assembly at runtime? What problems can I encounter?
Original question: StructureMap - Ability to replace an assembly at runtime
What is the difference in replacing an assembly at runtime within a web- and a non-web application?
回答1:
The difference is that IIS creates a new shadow copy each time you update a DLL. Hence you get a new AppDomain automatically when you add the new DLL.
WinForms etc doesn't do that magic for you and that's why it won't work.
回答2:
If the code that runs against that assembly runs in a separate AppDomain and that you shut down the appdomain before doing the operation, you should have no problem.
来源:https://stackoverflow.com/questions/7554342/component-based-architecture-replacing-an-assembly-at-runtime