473,513 Members | 13,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AppDomain.Unload

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
4 6075

"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
380
by: Satinderpal Singh | last post by:
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...
4
4182
by: stu_pb | last post by:
I am designing a plugin system for a window application using .NET(C# specifically). One of the requirements of the plugin system is to be able to dynamically load/unload plugins. My initial...
4
2333
by: Chris Lacey | last post by:
Hi, I'm currently writing a scheduling service which starts a number DotNet executables, each within a new AppDomain, every ten seconds. The guts of the code is as follows: // For each...
2
10821
by: Lauren Hines | last post by:
Hello, I have read numerous post stating that the only way to unload an assembly (DLL in my case) is to create a separate AppDomain, load the assembly, then unload it by calling AppDomain.Unload....
6
8171
by: Wal Turner | last post by:
Hi there. There are various snippets on forums regarding issues with AppDomain.Unload and how it just doesnt work. Fortunately, I got it working with the base case, after much fiddling. Consider...
4
370
by: Mirano | last post by:
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...
22
3780
by: JPSutor | last post by:
when I use the AppDomain.UnLoad method (which calls the Thread.Abort method), I get the following error message AppDomain can not be unloaded because the thread 1378 can not be unwound out of it...
3
2595
by: Tao | last post by:
hi.. group, A wired question about FileSystemWatcher and Unload an AppDomain. I have a class A which creates class B. When B is created, B loads an AppDomain and execute some functions on the...
2
5548
by: Tim | last post by:
Hello, I've finally managed to remotely load a DLL. I've expanded the code to load it in a seperate domain to unload the appdomain, which works to a certain extend. The host application always...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.