开发者

Is there a way to dynamically reload and then reuse dll and all its classes when app is running?

My target is below scenario:

  • I started application (Win32)

  • The application uses a set of classes from some .NET Class library.

  • I change some code in this .NET Class library, compile new dll

  • In my running application i destruct a开发者_运维问答ll the objects from this library and reload it.

  • My app is still running and all code changes are done!

I suppose that Spiring.NET (or similar framework) provides such functionality and need Your help.

Thanks a lot!


You can not unload an assembly once you loaded it. You can however unload an AppDomain. So the way this is done in .NET is to load that assembly in a seprate AppDomain that later can be unloaded again. Here is a simple example how to do it.

However, this approach has the downside that the objects you want to call from the other assembly must derive from MarshalByRefObject Alternatively you could use the System.Addin framework.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜