469,898 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

AppDomain Issue...

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
Nov 22 '05 #1
2 2245
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.

"Satinderpal Singh" <sa**********@planetasia.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl...
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

Nov 22 '05 #2
Hi,

Please find the code:

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

SetupInfo.ApplicationName="SimpleForm";

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

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

Form oHandle = (Form)MyNewDomain.CreateInstanceAndUnwrap("SimpleF orm", "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


"Dave" <no****************@wi.rr.com> wrote in message news:OI**************@TK2MSFTNGP10.phx.gbl...
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.

"Satinderpal Singh" <sa**********@planetasia.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl...
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


Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Satinderpal Singh | last post: by
8 posts views Thread by A. Elamiri | last post: by
1 post views Thread by BuddyWork | last post: by
1 post views Thread by Andrew Ducker | last post: by
10 posts views Thread by =?Utf-8?B?U3RlZmFuIEJhcmxvdw==?= | last post: by
4 posts views Thread by illegal.prime | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.