By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

AppDomain.Unload

P: n/a
Hi everybody.

I load an assembly into another AppDomain, not a default one. As there is no
way to unload the assembly, I need to unload the domain. This is where the
app hangs.
The problem is this assembly has references to one dll, currently not
performing any work.
I tried this:
1. Setting the assembly to null,
2. Implementing a ClassFactory and returning an interface of the object,
then removing it,
3. Making assembly to implement the IDisposable interface.

None of this works. All examples on the Net just shows how to create
AppDomains, load assemblies and then unload the AppDomain. None of those show
what happens if the assembly has referenced assemblies.

Thank you for your help.
Oct 11 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Mirano" <Mi****@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
Hi everybody.

I load an assembly into another AppDomain, not a default one. As there is
no
way to unload the assembly, I need to unload the domain. This is where the
app hangs.
The problem is this assembly has references to one dll, currently not
performing any work.
I tried this:
1. Setting the assembly to null,
2. Implementing a ClassFactory and returning an interface of the object,
then removing it,
3. Making assembly to implement the IDisposable interface.

None of this works. All examples on the Net just shows how to create
AppDomains, load assemblies and then unload the AppDomain. None of those
show
what happens if the assembly has referenced assemblies.


What do you mean by referenced assemblies? Are you sure the problem is due
to a assembly reference and not something else?
Oct 11 '05 #2

P: n/a
Simply having one assembly reference another assembly does not do
anythything...code must get executed so that the JIT loads the referenced
assembly. e.g. if one assembly references a type defined in the other
assembly, even if no methods are called, the referenced assembly will get
loaded. Further, you can only hang on unloading an appdomain if a thread
with stack in the doomed appdomain calls out to unmanaged code and the call
never returns.

So if you are really experiencing a hung app when the appdomain unloads
there must have been a whole lot more going on then what you are telling us.

"Mirano" <Mi****@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
Hi everybody.

I load an assembly into another AppDomain, not a default one. As there is
no
way to unload the assembly, I need to unload the domain. This is where the
app hangs.
The problem is this assembly has references to one dll, currently not
performing any work.
I tried this:
1. Setting the assembly to null,
2. Implementing a ClassFactory and returning an interface of the object,
then removing it,
3. Making assembly to implement the IDisposable interface.

None of this works. All examples on the Net just shows how to create
AppDomains, load assemblies and then unload the AppDomain. None of those
show
what happens if the assembly has referenced assemblies.

Thank you for your help.

Oct 11 '05 #3

P: n/a
Yes, of course I go Activator.CreateInstance and load the main assembly,
while the main assembly (for now) just creates the object of the referenced
assembly (which is simply a dll) not calling any methods.
No unmanaged code is accessed anywhere.
These assemblies will perform some tasks that the main service will never
know about, it is used to just start them off, so I can not use some manager
service to get into the AppDomains and manage the execution.
The problem is why this unloading of the AppDomain hangs the application,
when unloading of the AppDomain with a single assembly works just fine.
The situation will get even worse when there will be more assemblies that
the main assembly references and uses, and when those assemblies start to do
some work, creating the threads on their own, etc... when even this simple
setup with a main assembly and one referenced assembly does not work.
This is corrected in .Net 2.0 when unloading works just fine, and you can do
a lot more there, but I build under 1.1 Framework

Thanks.

"David Levine" wrote:
Simply having one assembly reference another assembly does not do
anythything...code must get executed so that the JIT loads the referenced
assembly. e.g. if one assembly references a type defined in the other
assembly, even if no methods are called, the referenced assembly will get
loaded. Further, you can only hang on unloading an appdomain if a thread
with stack in the doomed appdomain calls out to unmanaged code and the call
never returns.

So if you are really experiencing a hung app when the appdomain unloads
there must have been a whole lot more going on then what you are telling us.

"Mirano" <Mi****@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
Hi everybody.

I load an assembly into another AppDomain, not a default one. As there is
no
way to unload the assembly, I need to unload the domain. This is where the
app hangs.
The problem is this assembly has references to one dll, currently not
performing any work.
I tried this:
1. Setting the assembly to null,
2. Implementing a ClassFactory and returning an interface of the object,
then removing it,
3. Making assembly to implement the IDisposable interface.

None of this works. All examples on the Net just shows how to create
AppDomains, load assemblies and then unload the AppDomain. None of those
show
what happens if the assembly has referenced assemblies.

Thank you for your help.


Oct 11 '05 #4

P: n/a
Without more information I cannot begin to tell why your app is hanging. I
create and unload appdomains all the time without experiencing the problem
you are having. I do it from applications, window services, web services,
component libraries, etc.without it hanging. I currently do all my
development using the 1.1 framework, so if mine works so should yours.

Does this problem occur with any referenced assembly or only a specific one?

"Mirano" <Mi****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
Yes, of course I go Activator.CreateInstance and load the main assembly,
while the main assembly (for now) just creates the object of the
referenced
assembly (which is simply a dll) not calling any methods.
No unmanaged code is accessed anywhere.
These assemblies will perform some tasks that the main service will never
know about, it is used to just start them off, so I can not use some
manager
service to get into the AppDomains and manage the execution.
The problem is why this unloading of the AppDomain hangs the application,
when unloading of the AppDomain with a single assembly works just fine.
The situation will get even worse when there will be more assemblies that
the main assembly references and uses, and when those assemblies start to
do
some work, creating the threads on their own, etc... when even this simple
setup with a main assembly and one referenced assembly does not work.
This is corrected in .Net 2.0 when unloading works just fine, and you can
do
a lot more there, but I build under 1.1 Framework

Thanks.

"David Levine" wrote:
Simply having one assembly reference another assembly does not do
anythything...code must get executed so that the JIT loads the referenced
assembly. e.g. if one assembly references a type defined in the other
assembly, even if no methods are called, the referenced assembly will get
loaded. Further, you can only hang on unloading an appdomain if a thread
with stack in the doomed appdomain calls out to unmanaged code and the
call
never returns.

So if you are really experiencing a hung app when the appdomain unloads
there must have been a whole lot more going on then what you are telling
us.

"Mirano" <Mi****@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
> Hi everybody.
>
> I load an assembly into another AppDomain, not a default one. As there
> is
> no
> way to unload the assembly, I need to unload the domain. This is where
> the
> app hangs.
> The problem is this assembly has references to one dll, currently not
> performing any work.
> I tried this:
> 1. Setting the assembly to null,
> 2. Implementing a ClassFactory and returning an interface of the
> object,
> then removing it,
> 3. Making assembly to implement the IDisposable interface.
>
> None of this works. All examples on the Net just shows how to create
> AppDomains, load assemblies and then unload the AppDomain. None of
> those
> show
> what happens if the assembly has referenced assemblies.
>
> Thank you for your help.


Oct 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.