I use CSharpCodeProvider to compile the assembly, and I have the CompileParameters GenerateInMemory property set to true because I don't want to create a physical file.
After compiling, I can take CompilerResults and do something like this: -
object x = cr.CompiledAssembly.CreateInstance("MyGeneratedClass"); Console.WriteLine(x);
I get the expected result, CreateInstance worked.
However, I need to have access to types in the current AppDomain without such assembly knowledge. I need to do something like this: -
Type t = Type.GetType("MyGeneratedClass"); object x = Activator.CreateInstance(t);
The problem in this code t ends with zero. Now I suspect that although the assembly is compiled, it is not loaded. I can't seem to find this assembly in the domain so that its type names can be resolved.
Can someone enlighten me?
source share