473,385 Members | 1,712 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,385 software developers and data experts.

Accessing Members of Dynamically Loaded Assemblies

I plan to load an assembly during application startup, and load that
assembly via reflection (i.e., it isn't referenced in the application's
assembly manifest). The assembly will be loaded into the application's
default app domain, with code like this:

using System.Reflection;
Assembly loadedAssembly = Assembly.LoadFile(pathToMyAssembly);

My question: When I need to access members of the assembly [loaded via
reflection], how does the application know to get the member from the
dynamically loaded assembly [that is already loaded]? Am I required to get a
runtime reference to that dynamically loaded assembly? and execute GetType()
on that assembly reference?
Or will the Framework attempt to locate the assembly by first looking into
the current app domain before going to the assembly manifest to try to load
the assembly?

I have read up on assembly binding and probing rules and heuristics, but
what I have read assumes that the assembly is listed in the application's
assembly manifest... looks there, then goes through the normal probing
sequence. Is it possible that I've missed something ? and that the "normal
probing sequence" actually starts with the application's default application
domain and uses any loaded assembly before searching the GAC, /bin,
<probinglocations, etc?

Thanks.

Jun 27 '08 #1
1 1342
Jordan S. wrote:
I plan to load an assembly during application startup, and load that
assembly via reflection (i.e., it isn't referenced in the application's
assembly manifest). The assembly will be loaded into the application's
default app domain, with code like this:

using System.Reflection;
Assembly loadedAssembly = Assembly.LoadFile(pathToMyAssembly);

My question: When I need to access members of the assembly [loaded via
reflection], how does the application know to get the member from the
dynamically loaded assembly [that is already loaded]? Am I required to get a
runtime reference to that dynamically loaded assembly? and execute GetType()
on that assembly reference?
If any class you load already has a reference to that assembly then
there are no need to load it this way.

If you load it this way you will want to do something like:

IFoobar o = (IFoobar)loadedAssembly.CreateInstance("FoobarA");

where IFoobar is an interface the app knows and FoobarA is
an implementation that the app does not know.

Arne
Jun 27 '08 #2

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

Similar topics

3
by: lanky_tx | last post by:
Hi All, We have an automated build and test environment using NAnt and Nunit. Some of our assemblies are being strong named by modifying the AssemblyInfo.cs and having csc compile it. Some of...
6
by: Jimmy | last post by:
Hi, Sorry for the complete newb question, but none of the 3 books I own on C# cover this. If I place say, 10 or 15 functions in a codefile, what's the best method to call these functions from...
1
by: Robert Vasquez | last post by:
I would like my application to be able to load modules dynamically and release them once they aren't needed. For example in c++ I would load a dll containing the required function, run it, then...
0
by: Verane | last post by:
Hi all, I am working with C# and Visual studio 2003. What I want to do is the following : I have 3 assemblies, let call them A.exe, B.dll and C.dll. I want to dynamically load B and C when A...
6
by: mflanagan | last post by:
I have unmanaged C++ program that will load a managed C++ dll and then call a function in that dll. The managed C++ routine will call some C# routines. The unmanaged C++ main program will make...
2
by: brian.gabriel | last post by:
I have a core web service that acts as a gateway for several third party web services. Each one of the third party web services has it's own "interface" class derived from a main interface. When...
1
by: dnn | last post by:
How can I access dynamically loaded variables? I am trying to load an external javascript file dynamically and then access its variables. The script is loaded by the onload handler. The code...
2
by: Smithers | last post by:
Using 3.5, I am stuck in attempting to: 1. Dynamically load an assembly 2. Instantiate a class from that assembly (the client code is in a different namespace than the namespace of the...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...

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.