473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 6060

"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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...

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.