문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top