Loading different versions of the same assembly

后端 未结 2 1623
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 08:05

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 so

相关标签:
2条回答
  • 2021-01-17 08:12

    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

    0 讨论(0)
  • 2021-01-17 08:23

    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.

    0 讨论(0)
提交回复
热议问题