Compiling code at runtime, loading into current appdomain but Type.GetType cant see it

后端 未结 2 1542
孤街浪徒
孤街浪徒 2020-12-19 08:11

Im compiling some code at runtime then loading the assembly into the current appdomain, however when i then try to do Type.GetType it cant find the type...

Here is h

2条回答
  •  鱼传尺愫
    2020-12-19 08:50

    You should read a bit more about assembly loading, type resolution, ... I don't know exactly why your code works at all, but I guess you have the following problem:

    You compile the assembly and then you call AppDomain.CurrentDomain.Load to load the assembly. But you do not return the assembly you have just loaded. You return the assembly from the compilation result. Now you have two instances of the same assembly and you have each type from that assembly twice. These pairs have the same names, but they are not the same types!

提交回复
热议问题