AppDomain Issue...

  • Thread starter Thread starter Satinderpal Singh
  • Start date Start date
S

Satinderpal Singh

Hi All,

I have an EXE, I load the DLL from that exe in a seperate AppDomain. (I have
not given reference to that DLL from the EXE).

Now, i call some commands of that dll from the EXE, and in the background i
try to delete the DLL, it does not allows (fair enough).

Now, I unload that AppDomain using AppDomain.Unload method. Now, I try to
delete that DLL from the background it still does not allows, I thought the
reason could be Garbage Collector, but then I used System.GC.Collect
immediately after unloading the AppDomain, and also waited for 10-15 mins
before deleting it again, but it still does not allows, then i closed the
EXE and now it allows immediately.

What could be the reason ???

Does AppDomain works only for EXEs or is that we cannot unload an assembly
through AppDomain ???

I read few articles on net, www.gotdotnet.com says you can achieve the above
thing, but they have not given any example. Some articles says, this is not
possible, some says you use ShadowFolder of AppDomain to make this work,
with ShadowFolder it works fine, but i dont want to use it (i mean i dont
want to create a seperate folder and maintain a copy of my dll there).

Can anyone please help me out with this ?

I want to load and unload a DLL from the EXE and the moment I unload the
AppDomain of the DLL it should allow me to delete the DLL. This
functionality is to be achieved for AutoDeploy feature.

Thanks,
Satinder
 
If you are loading the DLL in a separate AppDomain then you should be able
to unload the appdomain and then delete/overwrite the assembly. I do it all
the time; ergo, you are probably not loading the dll in a separate
appdomain. Provide a code sample of how you create the appdomain and load
the dll and someone might be able to determine what the problem is.
 
Hi,

Please find the code:

In the click of Button1:
AppDomainSetup SetupInfo = new AppDomainSetup();

SetupInfo.ApplicationName="SimpleForm";

SetupInfo.ApplicationBase=@"D:\dotNet\VBApps\AppDomain-Process\bin\Debug";

MyNewDomain = AppDomain.CreateDomain("MyDomain",null,SetupInfo);

Form oHandle = (Form)MyNewDomain.CreateInstanceAndUnwrap("SimpleForm", "SimpleForm.Form1");

oHandle.Show();



And, in the click event of 2nd button i use:

AppDomain.Unload(MyNewDomain);



Clicking button1 shows a form, and clicking 2nd button unloads that form as we unload the domain.

btw, I am using .NET Framework 1.0 version ? has it something to do with the version ???



Thanks in advance,

Satinder
 
Back
Top