Pregunta

I used CSharpCodeProvider to compile and generate a new namespace in the memory for temporary use only. But this namespace should be deleted from the memory after certain period of time in order to allow for the next generated code to override the same identifiers of all generated classes and methods.

¿Fue útil?

Solución

There is only one way a loaded type can be unloaded: if it is a part of a collectible assembly.

But collectible assemblies can be only created through Reflection.Emit, not CSharpCodeProvider. Because of that, I'm not sure if using a collectible assembly is an option for you. If not, you will need some other option (like unloading AppDomains).

Otros consejos

No way. Class unload only happens - attention - when unloading a AppDomain.

Your best bet is to do all the code generation in a child-appdomain (will be same process), but that will not be trivial (the child appdomain needs proxies of all reachable object via remoting).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top