473,386 Members | 1,754 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.

Assembly.LoadFrom() & appDomains

I need to unload my loaded assembly. I have used LoadFrom to give me the flexability of loading the dll from any location.

However, to totally remove the assembly I need to unload the AppDomain, but I don't know how to initialy load the assembly into the AppDomain.

AppDomain newDomain = AppDomain.CreateDomain("newDomain", null, domainSetup);

assembly a = Assembly.LoadFrom(filename);

foreach (Type TypeAlgorithm in a.GetExportedTypes())
{
if (TypeAlgorithm.IsClass == true)
{
ObjAlgorithmInstance = Activator.CreateInstance(TypeAlgorithm);
methodInfo = ObjAlgorithmInstance.GetType().GetMethod("start");
methodInfo.Invoke(ObjAlgorithmInstance, new object[] { });
}
}

//NEED TO UNLOAD THE ASSEMBLY, BUT HOW???
May 8 '07 #1
2 2008
Have found a metod to load assembly into new domain. However, the dll file is locked and I cannot change its contence with the method os executing. I thought the ShadowCopyFile allows adjustments to assembly while its executing. Any suggestions

public static void LoadAssembly(String filename)
{
// Create application domain setup information.
AppDomainSetup domainSetup = new AppDomainSetup();
domainSetup.ShadowCopyFiles = "true";

//Create domain with setup parameters
AppDomain myDomain = AppDomain.CreateDomain("Algorithm", null, domainSetup);


//Create instance of class
Object objAlgorithm = myDomain.CreateInstanceFromAndUnwrap(@"I:\temp\alg orithmCS.dll", "Algorithms.algorithmCS");

//Execute specific member of the class
object[] arguments = new object[0];
objAlgorithm.GetType().InvokeMember("start",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
objAlgorithm, arguments);
//Unload assembly
AppDomain.Unload(myDomain);
myDomain = null;
objAlgorithm = null;
}
May 9 '07 #2
Answer at:

https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1575003&SiteID=1
May 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Arnaud Debaene | last post by:
Hello group. I have an app which can load "plugins" assemblies that are described in the registry (each registry entry gives the full path to the plugin ..dll file). The plugins may be anywhere...
3
by: Mike Krueger | last post by:
Hi I'm currently working on a forms designer for a free .NET IDE (SharpDevelop -> www.icsharpcode.net/OpenSource/SD). problem: I try to put 'custom' components (user controls from the current...
2
by: Greg Bacchus | last post by:
Hi, Does anyone know how to get an offline reference to an assembly that has been downloaded using Assembly.LoadFrom. E.g. Application downloads the assembly while it in online... next time it...
2
by: Bülent Üstün | last post by:
Hi, i've a DLL file which contains a class i wrote named up2date (its not windows.forms). Which contains a constructor public up2date(string url,string domain) Now i want to load this DLL & use...
0
by: Tony Wong | last post by:
I am trying to implement the Singleton Pattern for a assembly (class) which control a common resource on my computer. I need the Singleton behavior within a single process which contain multiple...
0
by: Brian Takita | last post by:
Hello, I'm getting the following error at the end of this message when trying to run the ReportManager and the ReportServer: Assembly system.data.dll security permission grant set is...
1
by: lgbjr | last post by:
Hi All, I am moving some of my MDI Child forms to DLLs. The first 3 forms worked fine. But the 4th one is causing me some grief! I use the following code to load a form from a DLL: Dim...
6
by: Steve | last post by:
I'm playing with late binding and trying a very simple test to load an assembly In my "Host" application I have this code: <code> string modulePath =...
4
by: =?Utf-8?B?SmFu?= | last post by:
I have a .NET 2.0 application divided in two assemblies; the exe and a dll. The application generates a plugin-dll which is then loaded in a separate AppDomain (along with a second instance of my...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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...

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.