Hi all,
Few day ago, I have a question about how to load assembly to another application domain. Now I met another issue.
My main application is running in COM+. Right now, already succeed to load dynamic compiled assembly to new application domain create within COM+ session. But the problem is: When I unload the domain and wish to delete the loaded assembly, but I can't.
(1) In the normal application (not COM+), I have succeed to compiled a C# file in runtime to assembly, then create new app domain -> load compiled assembly to new domain -> invoke method -> unload domain -> delete compiled assembly -> successfully.
(2) In COM+ application, I have succeed to compiled a C# file in runtime to assembly, then create new app domain -> load compiled assembly to new domain -> invoke method -> unload domain -> but cannot delete compiled assembly -> exception: the file was used by another process.
When running in debug mode, I've found the main difference is:
In (1) C# file store in D:\test.cs -> compile to test.dll assembly -> test.dll stored in D:\test.dll (same directory with C# file).
In (2) C# file store in D:\test.cs -> main application place in D:\MainApp -> compile to test.dll assembly -> test.dll stored in D:\MainApp\bin\Debug\test.dll and do not appear same as (1) D:\test.dll.
I think this is the reason why I cannot delete the assembly file.
Anyone please help me.