Loading different versions of the same assembly

▼魔方 西西 提交于 2019-12-01 13:44:19

问题


Using reflection, I need to load 2 different versions of the same assembly. Can I load the 2 versions in 2 different AppDomains in the same process?

I need to do some data migration from the old version of the app to the new version. Please let me know if this is possible or should I use 2 separate processes.


回答1:


If you are doing it at design time (which you indicate you are not) this should help you:

http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx

If you are doing it dynamically through reflection (looks like the case here) this might help you:

https://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html




回答2:


UPDATE: I thought I will post my findings as an answer. Reflection proved too complex in terms of development effort, tracking run time errors etc. I remember doing a different approach using 2 different processes when faced with a similar situation long time back (Thank you Brandon).

This is the plan: Nothing elegant but easier in terms of development and troubleshooting. Since it is a one time job, we just have to make it work.

Host a remoting process (which i call the server) having the new version of the application. A remoting client has references for the older version.

Remoting client instantiates and loads the objects with data required for migration. Convert the old objects into common serializable objects and pass as parameters to the server.

Remoting Server uses the common data to instantiate and load the new objects. Invokes the functions on the new types to persist their data.



来源:https://stackoverflow.com/questions/58035/loading-different-versions-of-the-same-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!