473,767 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Appdomain loading question

I'm trying to load an assembly into a temporary AppDomain rather than
my main AppDomain, so that it can be unloaded later on. However, it's
also loading into my main AppDomain at the same time.

My code is:
AppDomain a = AppDomain.Creat eDomain("TestDo main");
a.Load("AppDoma inTestAssembly" );

and in the Console window I get the following when the second line
executes:
'TestDomain': Loaded 'c:\visual studio
projects\appdom ain\appdomain\b in\debug\appdom aintestassembly .dll',
Symbols loaded.
'AppDomainTest. exe': Loaded 'c:\visual studio
projects\appdom ain\appdomain\b in\debug\appdom aintestassembly .dll',
Symbols loaded.

Which clearly means it's loading into both assemblies, yes? Is there a
reason why it's not just loading into TestDomain?

Cheers,

Andy D

Dec 7 '05 #1
1 1745
To load an assembly into another AppDomain "cleanly" you must do so without
loading any Type data into the main AppDomain.

MVP Ambrose Little has a couple of articles he calls the "Perfect Service"
that explains a very neat way to do this in great detail:

http://www.15seconds.com/issue/040624.htm

Pete
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Andrew Ducker" wrote:
I'm trying to load an assembly into a temporary AppDomain rather than
my main AppDomain, so that it can be unloaded later on. However, it's
also loading into my main AppDomain at the same time.

My code is:
AppDomain a = AppDomain.Creat eDomain("TestDo main");
a.Load("AppDoma inTestAssembly" );

and in the Console window I get the following when the second line
executes:
'TestDomain': Loaded 'c:\visual studio
projects\appdom ain\appdomain\b in\debug\appdom aintestassembly .dll',
Symbols loaded.
'AppDomainTest. exe': Loaded 'c:\visual studio
projects\appdom ain\appdomain\b in\debug\appdom aintestassembly .dll',
Symbols loaded.

Which clearly means it's loading into both assemblies, yes? Is there a
reason why it's not just loading into TestDomain?

Cheers,

Andy D

Dec 7 '05 #2

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 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
5
15371
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have the same class/static method definition statictly linked to my EXE and when I call InvokeMember(...), even though I got the Type from the new AppDomain, it calls the static method that I am staticly linked to and not the static method in the dynamicly...
2
3134
by: Foehammer | last post by:
Hello, I'm trying to load an assembly dynamically using an app domain. This is a proof-of-concept for a larger project, so please excuse the lame class names. TestLib is the dll where all the dynamic loading code will go. The assemblies being dynamically loaded do not contain any code. They are resource-only assemblies. I have succeeded in dynamically loading them within the same AppDomain as the main application (a Winforms EXE that...
2
10850
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. When trying to delete the DLL file I get an exception that access is denied. When trying to copy over the DLL file, I get an exception that it is being used by another process.
1
2491
by: Cider123 | last post by:
The following is a basic example of how this system works: C:\MyApp\Application1.exe C:\MyApp\MyMonitor.exe In SQL Server, we keep an EXE (Application1.exe) file stored as binary. I read this out of SQL Server into a byte array (through MyMonitor.exe) and then pass to a function for Version.
6
8200
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 this 5 line program: AppDomain domain = AppDomain.CreateDomain("MyDomain"); domain.CreateInstance("TempDLL", "TempDLL.Class1"); MessageBox.Show("try deleting file now"); //cant delete file AppDomain.Unload(domain);
22
3826
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 It seems to take time doing this. If I wait for about 30 seconds, it seems to get unloaded. Any ideas?
3
22148
by: Frank Uray | last post by:
Hi all I have a problem with loading a assembly ... I am trying to do the following: - I have a directory with a dll (assembly) in it (not the currect dir.) - I am trying to load this assembly, run a method in it, and than close it. The question would be: How is the right way to do it ????
4
5339
by: illegal.prime | last post by:
Hi all, I'm getting unexpected results when trying to preload assemblies into an AppDomain I'm creating. Upon creation of the AppDomain - I attach an AssemblyResolve to both my current AppDomain and the new AppDomain I create. I copy all the assemblies/dlls into a new directory and then try loading them all into the new AppDomain using the following: private void LoadAssembliesFromDirectory(AppDomain appDomain, string directory)
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10169
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9960
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8838
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.