473,396 Members | 2,052 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,396 software developers and data experts.

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\assembly", 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 3217
Hello RickN,

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

AppDomainSetup adSetup = new AppDomainSetup();
adSetup.ApplicationBase = @"C:\Mydata\assembly";
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\assembly", 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.ApplicationBase = @"C:\Mydata\assembly";
AppDomain app = AppDomain.CreateDomain(mydomain, 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("myassembly.dll"); //error w/orw/o
".dll" (myassembly is the assembly I want to load into the app AppDomain, it
is in the "C:\Mydata\assembly" folder.

If I copy the assembly to the local folder the above
app.Load("myassembly.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.ApplicationBase = @"C:\Mydata\assembly";
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\assembly", 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.ApplicationBase = @"C:\Mydata\assembly";
RAppDomain app = AppDomain.CreateDomain(mydomain,
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("myassembly.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\assembly" folder.
R>
RIf I copy the assembly to the local folder the above
Rapp.Load("myassembly.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.ApplicationBase = @"C:\Mydata\assembly";
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\assembly", 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.SerializationExceptio n
{"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.ApplicationBase = @"C:\Mydata\assembly";
RAppDomain app = AppDomain.CreateDomain(mydomain,
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("myassembly.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\assembly" folder.
R>
RIf I copy the assembly to the local folder the above
Rapp.Load("myassembly.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.ApplicationBase = @"C:\Mydata\assembly";
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\assembly", 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.ApplicationBase = @"C:\Mydata\assembly";
RAppDomain app = AppDomain.CreateDomain(mydomain,
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("myassembly.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\assembly" folder.
R>
RIf I copy the assembly to the local folder the above
Rapp.Load("myassembly.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.ApplicationBase = @"C:\Mydata\assembly";
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\assembly", 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
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...
4
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...
1
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...
9
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...
6
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,...
1
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...
4
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...
1
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...
5
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...
1
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...
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
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
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...
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...
0
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...
0
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...

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.