473,563 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Usage of AppDomain.Creat eInstanceFromAn dUnwrap method

i am trying to load a Windows Form Assembly at run time to a seprate AppDomain.
I don't want that this Assembly to be loaded in the Caller Domain, so i used the metho
CreateInstanceF romAndUnwrap instead of AppDomain.Load( ..
// I am passing the Control's parent through the constructor argumen
Object[] args1 = new Object[] {this}
AppDomainSetup info = new AppDomainSetup( )
info.Applicatio nBase = "file:///" + System.Environm ent.CurrentDire ctory
AppDomain MyDomain = AppDomain.Creat eDomain("MyDoma in", null, info)
MyControl.MyCon trol Ctrl = (MyControl.MyCo ntrol) MyDomain.Create InstanceFromAnd Unwrap("D:\Test \MyControl.dll" ,MyControl.MyCo ntrol
false,BindingFl ags.Public,null ,args1,null,nul l,null)
But when i do this i get an exception thrown "Constructo r on type MyControl.MyCon trol not found
What should be cause of this issue?

If i try to use the CreateInstanceF romAndUnwrap using the two parameters just the assembly and type, the functio
returns me the control object. But when i try to set the Parent of the control using the followin
code
Ctrl.Parent = this

then system throws an exception the message is
The type System.Windows. Forms.Form+Cont rolCollection in Assembly System.Windows. Forms, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 is not marked as serializable

What am i doing any thing wrong in this both scenarios
Or is it advisable to have a design where i can load my Windows Forms Assemblies in to a seprat
Domain and use, and later unload it

Any body please help....
Nov 16 '05 #1
0 2601

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
372
by: Vineeth Karinta | last post by:
i am trying to load a Windows Form Assembly at run time to a seprate AppDomain. I don't want that this Assembly to be loaded in the Caller Domain, so i used the metho CreateInstanceFromAndUnwrap instead of AppDomain.Load(.. // I am passing the Control's parent through the constructor argumen Object args1 = new Object {this} AppDomainSetup...
2
3112
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...
6
8184
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");...
0
1197
by: JonS. | last post by:
Hey All, I'm currently working on a program that dynamically loads assemblies from a directory each into their own seperate AppDomains using a somewhat logical extension of Eric Gunnerson's article found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp Now the problem I'm having is that,...
3
3954
by: ZhangZQ | last post by:
Supposing I have a class "UserControl1 : System.Windows.Forms.UserControl" in an Assembly "UI.dll", now I create an Application project and want to use the "UserControl1" in another AppDomain, private void CreateUIInAnotherDomain() { UI.UserControl1 ui = (UI.Cls)domain.CreateInstanceFromAndUnwrap(@".\UI.dll", "UI.UserControl1"); ...
0
962
by: marfi95 | last post by:
Hi all, I'm writing some code to automatically update my application when changes have been made. I had it all working by using the LoadFrom method of an assembly and checking the version information, etc... until I realized that was actually locking the files on the common drive where the updated app is located. I know the solution to...
5
11005
by: Benny Raymond | last post by:
What should I do instead of this: AppDomain.CurrentDomain.AppendPrivatePath(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"\plugins"); now that AppDomain.CurrentDomain.AppendPrivatePath is depreciated?
0
1391
by: Mick | last post by:
Hello all! Can anybody provide a good example for the Reflectio.Emitl namespace usage? The problem I'm trying to solve is copying the method body from existing class to newly created one. Below is the code targeting .Net 2.0 , that I'm trying to use without success: class TemplateOne { public void PrintTemplateOne()
0
2096
by: Michael | last post by:
Hi Everyone, I'm having a problem loadin a assembly into memory. Here is the code I'm trying to run(Its a C# convert from an article (Search Dynamically for Plug-ins): Dim domain As AppDomain = AppDomain.CreateDomain("PluginLoader") Dim finder As PluginFinder = CType(domain.CreateInstanceFromAndUnwrap(Application.ExecutablePath ,...
1
2091
by: ThunderMusic | last post by:
Hi, (My code is at the end of this post) I have an AppDomain that must load a simple assembly that has only one class with one method and it does not work... I receive this exception : "Could not load file or assembly 'ModuleLoader.dll' or one of its dependencies. The system cannot find the file specified." Does anyone have an idea of...
0
7664
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...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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...
0
6250
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...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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...
0
3642
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.