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.
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
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.