Recognizing an object instance after regenerating dinamicly the assembly
-
Hi, I'm working on generating dynamically an assembly to let a user customize things. To do that, I used
CSharpCodeProvider
to generate the assembly and that worked fine till I encountered the problem of recognizing an instance created with the first version of the assembly after getting a second version. So here are the steps I followed: 1- I generated an assembly containing a class called "Class_1" which just has an attribute called "Name". 2- I created instance of that and added it to a set. For now, I can display all the item of the set (I used a main class Root which is created not dynamically and from which all the dynamic classes will inherit from). 3- I regenerated the assembly after adding "Class_2" which inherits from Root too and have a method that get as parameter a "Class_1" instance and that displays the name of the instance. 4- I created an instance of the second class and called its method with the "Class_1" instance that I created before. Doing that raised the following exception:Object of type 'TestProject_CustomClassesLibrary.Class_1' cannot be converted to type 'TestProject_CustomClassesLibrary.Class_1'.
I searched on the net about that and I found multiple things: * Signing the assembly the GAC but when I tried it, nothing changed. * Using domain application but this require stopping the application each time we want to generate I guess (did not tried it by the way). So that's not a solution for me. Is there any solution for that? What should I do to make this work? Thanks for all.