473,769 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loading assembly

I want to creat a new application domain called 'mydomain' and then load an
assembly named 'myassembly.dll ' into the domain. The assembly is in the
folder "C:\Mydata\asse mbly", which is not the running program folder. I then
want to load the 'MainClass" found in 'myassembly'. I'm having a little
trouble loading because the assembly is not in the program folder.

Any suggestions.
Thanks,
--
Rick
Aug 5 '06 #1
5 3247
Hello RickN,

You can use AppDomainSetup. ApplicationBase to set where are you assemblies
located
like

AppDomainSetup adSetup = new AppDomainSetup( );
adSetup.Applica tionBase = @"C:\Mydata\ass embly";
RI want to creat a new application domain called 'mydomain' and then
Rload an assembly named 'myassembly.dll ' into the domain. The
Rassembly is in the folder "C:\Mydata\asse mbly", which is not the
Rrunning program folder. I then want to load the 'MainClass" found in
R'myassembly'. I'm having a little trouble loading because the
Rassembly is not in the program folder.
R>
RAny suggestions.
RThanks,
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 5 '06 #2
Thanks Michael:
Even with referencing the path in the AppDomainSetup, I still get an error.
The error doesn't seem to be related to the path.
Here is a representation of my code.

AppDomainSetup info = new AppDomainSetup( );
info.Applicatio nBase = @"C:\Mydata\ass embly";
AppDomain app = AppDomain.Creat eDomain(mydomai n, null, info);
//so far so good.
//the next step throws an exception: "Type not resolved for ...--it then
references the calling assembly.
Assembly asm = app.Load("myass embly.dll"); //error w/orw/o
".dll" (myassembly is the assembly I want to load into the app AppDomain, it
is in the "C:\Mydata\asse mbly" folder.

If I copy the assembly to the local folder the above
app.Load("myass embly.dll") code works.
Any suggestions are appreciated.

Thanks,
Rick

--
Rick
"Michael Nemtsev" wrote:
Hello RickN,

You can use AppDomainSetup. ApplicationBase to set where are you assemblies
located
like

AppDomainSetup adSetup = new AppDomainSetup( );
adSetup.Applica tionBase = @"C:\Mydata\ass embly";
RI want to creat a new application domain called 'mydomain' and then
Rload an assembly named 'myassembly.dll ' into the domain. The
Rassembly is in the folder "C:\Mydata\asse mbly", which is not the
Rrunning program folder. I then want to load the 'MainClass" found in
R'myassembly'. I'm having a little trouble loading because the
Rassembly is not in the program folder.
R>
RAny suggestions.
RThanks,
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 5 '06 #3
Hello RickN,

Check that AppDomainSetup. PrivateBinPath is pointed on the same directory
And try to specify the fully quialified name of you myassembly.dll in the
app.Load
RThanks Michael:
REven with referencing the path in the AppDomainSetup, I still get an
Rerror.
RThe error doesn't seem to be related to the path.
RHere is a representation of my code.
RAppDomainSetup info = new AppDomainSetup( );
Rinfo.Applicati onBase = @"C:\Mydata\ass embly";
RAppDomain app = AppDomain.Creat eDomain(mydomai n,
Rnull, info);
R//so far so good.
R//the next step throws an exception: "Type not resolved for ...--it
Rthen
Rreferences the calling assembly.
RAssembly asm = app.Load("myass embly.dll"); //error
Rw/orw/o
R".dll" (myassembly is the assembly I want to load into the app
RAppDomain, it
Ris in the "C:\Mydata\asse mbly" folder.
R>
RIf I copy the assembly to the local folder the above
Rapp.Load("myas sembly.dll") code works.
RAny suggestions are appreciated.
RThanks,
RRick
R"Michael Nemtsev" wrote:
R>
>Hello RickN,

You can use AppDomainSetup. ApplicationBase to set where are you
assemblies
located
like
AppDomainSet up adSetup = new AppDomainSetup( );
adSetup.Applic ationBase = @"C:\Mydata\ass embly";
RI want to creat a new application domain called 'mydomain' and
then
Rload an assembly named 'myassembly.dll ' into the domain. The
Rassembly is in the folder "C:\Mydata\asse mbly", which is not the
Rrunning program folder. I then want to load the 'MainClass" found
in
R'myassembly '. I'm having a little trouble loading because the
Rassembly is not in the program folder.
R>
RAny suggestions.
RThanks,
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 5 '06 #4
I set the PrivateBinPath to the same path and tried every variation I can
think of on the Load. I get the same error:
System.RunTime. Serialization.S erializationExc eption
{"Type is not resolved for member ...(plus reference to calling assembly)
(I think my previous statement that it loaded from the local folder was in
error.)

Everything else being the same, if I try to load the same dll into an
assembly (no AppDomain), it works just fine using LoadFrom. However, I need
to be able to unload the assembly, so I need the assembly in the new
AppDomain not the default AppDomain.

Any suggestions are appreciated.
Thanks,
Rick
--
Rick
"Michael Nemtsev" wrote:
Hello RickN,

Check that AppDomainSetup. PrivateBinPath is pointed on the same directory
And try to specify the fully quialified name of you myassembly.dll in the
app.Load
RThanks Michael:
REven with referencing the path in the AppDomainSetup, I still get an
Rerror.
RThe error doesn't seem to be related to the path.
RHere is a representation of my code.
RAppDomainSetup info = new AppDomainSetup( );
Rinfo.Applicati onBase = @"C:\Mydata\ass embly";
RAppDomain app = AppDomain.Creat eDomain(mydomai n,
Rnull, info);
R//so far so good.
R//the next step throws an exception: "Type not resolved for ...--it
Rthen
Rreferences the calling assembly.
RAssembly asm = app.Load("myass embly.dll"); //error
Rw/orw/o
R".dll" (myassembly is the assembly I want to load into the app
RAppDomain, it
Ris in the "C:\Mydata\asse mbly" folder.
R>
RIf I copy the assembly to the local folder the above
Rapp.Load("myas sembly.dll") code works.
RAny suggestions are appreciated.
RThanks,
RRick
R"Michael Nemtsev" wrote:
R>
Hello RickN,

You can use AppDomainSetup. ApplicationBase to set where are you
assemblies
located
like
AppDomainSetup adSetup = new AppDomainSetup( );
adSetup.Applica tionBase = @"C:\Mydata\ass embly";
RI want to creat a new application domain called 'mydomain' and
then
Rload an assembly named 'myassembly.dll ' into the domain. The
Rassembly is in the folder "C:\Mydata\asse mbly", which is not the
Rrunning program folder. I then want to load the 'MainClass" found
in
R'myassembly'. I'm having a little trouble loading because the
Rassembly is not in the program folder.
R>
RAny suggestions.
RThanks,
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 5 '06 #5
Michael

I've found a solution.
I rebuilt the external dll and modified the class in the dll to inherit from
MarshallByRef. Once I did that, the assembly loaded into the appdomain.

Thanks for your help.
--
Rick
"Michael Nemtsev" wrote:
Hello RickN,

Check that AppDomainSetup. PrivateBinPath is pointed on the same directory
And try to specify the fully quialified name of you myassembly.dll in the
app.Load
RThanks Michael:
REven with referencing the path in the AppDomainSetup, I still get an
Rerror.
RThe error doesn't seem to be related to the path.
RHere is a representation of my code.
RAppDomainSetup info = new AppDomainSetup( );
Rinfo.Applicati onBase = @"C:\Mydata\ass embly";
RAppDomain app = AppDomain.Creat eDomain(mydomai n,
Rnull, info);
R//so far so good.
R//the next step throws an exception: "Type not resolved for ...--it
Rthen
Rreferences the calling assembly.
RAssembly asm = app.Load("myass embly.dll"); //error
Rw/orw/o
R".dll" (myassembly is the assembly I want to load into the app
RAppDomain, it
Ris in the "C:\Mydata\asse mbly" folder.
R>
RIf I copy the assembly to the local folder the above
Rapp.Load("myas sembly.dll") code works.
RAny suggestions are appreciated.
RThanks,
RRick
R"Michael Nemtsev" wrote:
R>
Hello RickN,

You can use AppDomainSetup. ApplicationBase to set where are you
assemblies
located
like
AppDomainSetup adSetup = new AppDomainSetup( );
adSetup.Applica tionBase = @"C:\Mydata\ass embly";
RI want to creat a new application domain called 'mydomain' and
then
Rload an assembly named 'myassembly.dll ' into the domain. The
Rassembly is in the folder "C:\Mydata\asse mbly", which is not the
Rrunning program folder. I then want to load the 'MainClass" found
in
R'myassembly'. I'm having a little trouble loading because the
Rassembly is not in the program folder.
R>
RAny suggestions.
RThanks,
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 6 '06 #6

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

Similar topics

2
3138
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...
4
2880
by: Mark | last post by:
I wan't to be able to deserialize a class from an assembly that is not in the application domain. To do that I must have the Type from the Assembly. How do you get a Type from an assembly that is not in the manifest of the current AppDomain. I have tried different ways but get exceptions from all of them that say the: assembly or one of its dependancies could not be found. There must be missing something.
1
5022
by: Benjamin | last post by:
Hi, I'm currently writing a Web Services that interacts with a database. To allow me to use not just one database provider (for example, I could use MS Access, SQL Server or MySQL), the Web Service dynamically loads up an assembly that implements an Interface I called IDatabase. To load the assembly and create an object, I wrote this function: private IDatabase LoadDatabasePlugin( string assemblyFile, string
9
4493
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the "Let Users Add Functionality to Your .NET Applications with Macros and Plug-Ins" article at MSDN for the dynamic loading of DLLs http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
6
4503
by: Pete Davis | last post by:
I'm confused about what precisely the limitations are on loading plugins in separate app domains. In all my previous apps that supported plugins, I've loaded them into the same domain as the app, but I've just started playing around with separate AppDomains and I'm finding that I'm not having problems where I expected I would, so maybe someone can help me understand a bit better. I've read that objects instantiated in separate AppDomains...
1
2928
by: Brian | last post by:
I've looked through the previous posts on this one and have verified permissions and location of my Dlls, but I am still getting an exception when I try to Load an assembly. The directory where my Dlls are located give the ASPNET user full control, and all Dlls used by the Assembly in question are in the local folder with the rest of the web application Dlls. Could someone take a look at my error and shed some light on this?
4
5728
by: ali.jan | last post by:
Hi, It is trivial to load an assembly in a new Application Domain. Is there any way of loading an assembly in a new process? I tried using the Process class like this: Process p = new Process() p.StartInfo.FileName = mStartupFile p.StartInfo.UseShellExecute = False
1
1863
by: John F | last post by:
Hello all, When dynamically loading classes through reflection using Assembly.LoadFrom I have the following questions: 1) Once you load an assembly it doesn't appear you can unload it. If you try to load an assembly multiple times does this cause any type of memory issues? 2) If you load an assembly and later you try to load a newer version of the
5
1778
by: Mantorok | last post by:
Hi I have a project that references one of our components, is there a way in ..Net to get a list of references that the application is depending on? The reason for this is so I can load certain dlls on app startup. Thanks Kev
1
2241
by: =?Windows-1252?Q?Tor_B=E5dshaug?= | last post by:
BlankHi, I am having trouble loading assemblies from the database in my ASP.NET app. I have a default.aspx in my app that is served from a database via a custom virtual path provider. This works fine, until this default.aspx uses code in a dependent assembly (say CustomAssembly). Then ASP.NET cannot find the class "CustomAssembly.MyClass" and files to compile the default.aspx. I've tried to do a AppDomain.CurrentDomain.Load(byte...
0
9415
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10198
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...
0
10032
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9978
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
9848
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
8860
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
5293
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...
1
3947
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 we have to send another system
2
3551
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.