I have the predicament of having to load several assemblies on the fly and
when I do so, I get an exception stating that one of the referenced
assemblies cannot be found. Is there any way to recurse into an assembly to
discover the referenced assemblies without actually loading the root assembly
where I start the load?
For example:
assembly 1 contains references to assembly 1_1 and assembly 1_2
assembly 1_1 contains reference to assembly 2
assembly 1_2 contains reference to assembly 3
If I attempt to load assembly 1 in order to get the AssemblyNames[] of it's
referenced assemblies, I get an exception on the Load() call because the
referenced assemblies cannot be found. I have them all in the same directory,
by the way. 2 2636
To my knowledge no.. But what you can do is handle the missing assembly
exception and try to locate the assembly, copy it to the path, and start
your code. Also remember that .. the search path, current executable path,
GAC and so on.. You can alter this with App.Config / make it search in a
specific path for your dll's. If you still have the assembly in the same
path and getting the error.. , you might want to check the complete
reference hierarchy out.. There must be something broken in the chain, you
could also use stacktrace in the exception to examine any possible breaks in
reference.
HTH
VJ
"jnick" <jn***@discussi ons.microsoft.c om> wrote in message
news:94******** *************** ***********@mic rosoft.com... I have the predicament of having to load several assemblies on the fly and when I do so, I get an exception stating that one of the referenced assemblies cannot be found. Is there any way to recurse into an assembly to discover the referenced assemblies without actually loading the root assembly where I start the load? For example:
assembly 1 contains references to assembly 1_1 and assembly 1_2 assembly 1_1 contains reference to assembly 2 assembly 1_2 contains reference to assembly 3
If I attempt to load assembly 1 in order to get the AssemblyNames[] of it's referenced assemblies, I get an exception on the Load() call because the referenced assemblies cannot be found. I have them all in the same directory, by the way.
There's an AssemblyResolve event off of the AppDomain class that could help...
Something like:
AppDomain.Curre ntDomain.Assemb lyResolve += new
ResolveEventHan dler(CurrentDom ain_AssemblyRes olve);
then:
private Assembly CurrentDomain_A ssemblyResolve( object sender,
ResolveEventArg s args)
{
return Assembly.LoadFr om(fileName);
}
Granted you'll probably need some logic to locate/load the appropriate
library from the event handler method.
"Vijay" wrote: To my knowledge no.. But what you can do is handle the missing assembly exception and try to locate the assembly, copy it to the path, and start your code. Also remember that .. the search path, current executable path, GAC and so on.. You can alter this with App.Config / make it search in a specific path for your dll's. If you still have the assembly in the same path and getting the error.. , you might want to check the complete reference hierarchy out.. There must be something broken in the chain, you could also use stacktrace in the exception to examine any possible breaks in reference.
HTH VJ
"jnick" <jn***@discussi ons.microsoft.c om> wrote in message news:94******** *************** ***********@mic rosoft.com...I have the predicament of having to load several assemblies on the fly and when I do so, I get an exception stating that one of the referenced assemblies cannot be found. Is there any way to recurse into an assembly to discover the referenced assemblies without actually loading the root assembly where I start the load? For example:
assembly 1 contains references to assembly 1_1 and assembly 1_2 assembly 1_1 contains reference to assembly 2 assembly 1_2 contains reference to assembly 3
If I attempt to load assembly 1 in order to get the AssemblyNames[] of it's referenced assemblies, I get an exception on the Load() call because the referenced assemblies cannot be found. I have them all in the same directory, by the way. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jozsef Bekes |
last post by:
Hi All,
I am trying to use reflection for getting all the classes from the dlls of a
software written by my company. I am using this line:
Assembly.LoadFile(s).GetTypes()
Gettypes fails, I guess because when one dll refers to another one of mine,
Reflection does not find that dll. This is what the exception contains
anyway. So I realized that I'd need to copy the dlls, or register them to
|
by: Jimi |
last post by:
Given a C# project file path, can I use reflection to get all the
assemblies referenced by the project?
e.g., I know the path of a C# project, say, "c:\SomeProject.csproj",
and I want to load its referenced assemblies to construct a list of
their members for display. Note that "c:\SomeProject.csproj" is not
the current project, it's just a project we're displaying information
about in the utility I'm trying to construct.
|
by: Eyeawanda Pondicherry |
last post by:
I have put some code together that creates an enum dynamically from some
database values.
The enum can be read perfectly by an application that references the
dynamically generated dll.
If I /emit/ a new version of the assembly, and start the application
again, the new values will appear for the enum.
However, suppose I want the application to remain in a running state.
|
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...
|
by: Bob |
last post by:
I need to be able to remotely load all referenced assemblies of an
executable. The example code below works fine when all referenced assemblies
are either 1. copied locally or 2. registered in the GAC. But if you have
enough DLL's in a hierarchy, copying all references locally cause them to
trip over each other which is a major pain in the ass. And I don't want to
have to register everything in the GAC. Could someone help me get this...
| |
by: Doug Handler |
last post by:
Ok,
I think this is my last one - in my app, the user can select via a dialog
box the dll's they want to load. I use a checkbox to track this (no worries
there), but, once a dll has been bound, how can i make sure that during the
session that a dll can't be bound twice? I'm assuming there's "protection"
w/i the reflection process to stop this, (if so, is there an exception that
is thrown? ), if not, what can i do to stop this from...
|
by: npthomson |
last post by:
Hi all,
This could get a bit complicated but I'll try to be as clear as
possible. I've written an application that discovers plugins at
runtime using reflection from a subdirectory of the application, eg:
In the directory the application is installed to:
\application.exe
\plugins\plugin1.dll
|
by: =?Utf-8?B?VzFsZDBuZTc0?= |
last post by:
When one architects a new project one of the first steps in the decision is
to decide on the layers. (In my opinion anyway)
One architecture that I have used before is to go solid OO and create
objects, which normally are very small and only deals with the stuff
pertaining to that object, then break it down into Business Process, Process
Controllers and Data Access Objects for each "Object", each of which is
created in it's very own .Net...
|
by: =?Utf-8?B?TWFyaw==?= |
last post by:
We've got a wierd failure happening on just one machine. One part of our
product uses a 3rd party search implementation (dtSearch). DtSearch has a
native core (dten600.dll), late-bound, and a managed wrapper
(dtSearchNetApi2.dll).
For reasons unknown our build and msi packaging process includes
dtSearchNetApi2.dll but not dten600.dll in all packages, as well as a couple
of assemblies that reference it, even though they are not used by...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |