473,847 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically loading DLLs dynamically that have dependencies...

I actually have two questions here, but I'll start by giving an outline
of what I'm trying to do.

I'm building an app with a simple plugin architecture (all in the same
app domain). I have each plugin in a separate sub-dir inside a
"Plugins" directory. Each plugin consists of at least two DLLs (a
controller and a driver). However, most drivers also rely on other
external DLLs.

In one particular case this dependency is to a C++ DLL called
PF_DTMF_Connect or.dll which in turn is dependent on another C/C++ DLL
in the windows\system3 2 folder.

My first question is what this error message means and how can I
resolve it? When I dynamically load my driver DLL up for this
particular plugin I get the error message below. Note that if I include
my driver code as a normal project, I don't get this error. Also note
that although I do get this error, at least some of the functionality
of this DLL DOES work. This DLL is located right with the plugin using
it. Is this DLL having trouble finding it's dependent DLL that's in the
windows\system3 2 directory? If so, how would I correct this?

at System.Reflecti on.Assembly.nLo ad(AssemblyName fileName, String
codeBase, Evidence assemblySecurit y, Assembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotF ound, Boolean
forIntrospectio n)
[Could not load file or assembly
'file:///C:\working\IQ\v 6.0\DTMFTester\ bin\Debug\Plugi ns\Enumeration\ PF_DTMF_Connect or.dll'
or one of its dependencies. The module was expected to contain an
assembly manifest.] :
at System.Reflecti on.Assembly.Int ernalLoad(Assem blyName assemblyRef,
Evidence assemblySecurit y, StackCrawlMark& stackMark, Boolean
forIntrospectio n)
at System.Reflecti on.Assembly.Int ernalLoadFrom(S tring assemblyFile,
Evidence securityEvidenc e, Byte[] hashValue, AssemblyHashAlg orithm
hashAlgorithm, Boolean forIntrospectio n, StackCrawlMark& stackMark)
at System.Reflecti on.Assembly.Loa dFrom(String assemblyFile)

My second question relates to another plugin I wrote. It's driver DLL
depends on another (managed) DLL. When I put this dependent DLL in the
same directory as the plugin, it can't find it. If I move this
dependent DLL to the root directory of the application it all works
fine. How can I get it to seach the directory that the plugin is in? I
tried using the <probeattribu te in the app.config but without any
luck.

Any direction with either of these problems would greatly be
appreciated!

Dan

Jul 13 '06 #1
6 6884
Dan Dorey <da*******@gmai l.comwrote:
I actually have two questions here, but I'll start by giving an outline
of what I'm trying to do.

I'm building an app with a simple plugin architecture (all in the same
app domain). I have each plugin in a separate sub-dir inside a
"Plugins" directory. Each plugin consists of at least two DLLs (a
controller and a driver). However, most drivers also rely on other
external DLLs.

In one particular case this dependency is to a C++ DLL called
PF_DTMF_Connect or.dll which in turn is dependent on another C/C++ DLL
in the windows\system3 2 folder.

My first question is what this error message means and how can I
resolve it? When I dynamically load my driver DLL up for this
particular plugin I get the error message below. Note that if I include
my driver code as a normal project, I don't get this error. Also note
that although I do get this error, at least some of the functionality
of this DLL DOES work. This DLL is located right with the plugin using
it. Is this DLL having trouble finding it's dependent DLL that's in the
windows\system3 2 directory? If so, how would I correct this?

at System.Reflecti on.Assembly.nLo ad(AssemblyName fileName, String
codeBase, Evidence assemblySecurit y, Assembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotF ound, Boolean
forIntrospectio n)
[Could not load file or assembly
'file:///C:\working\IQ\v 6.0\DTMFTester\ bin\Debug\Plugi ns\Enumeration\ PF_DTMF_Connect or.dll'
or one of its dependencies. The module was expected to contain an
assembly manifest.] :
at System.Reflecti on.Assembly.Int ernalLoad(Assem blyName assemblyRef,
Evidence assemblySecurit y, StackCrawlMark& stackMark, Boolean
forIntrospectio n)
at System.Reflecti on.Assembly.Int ernalLoadFrom(S tring assemblyFile,
Evidence securityEvidenc e, Byte[] hashValue, AssemblyHashAlg orithm
hashAlgorithm, Boolean forIntrospectio n, StackCrawlMark& stackMark)
at System.Reflecti on.Assembly.Loa dFrom(String assemblyFile)
This is telling you that you are trying to load a non-assembly DLL (not all
DLLs are assemblies). You should use DLL Imports and link directly.
My second question relates to another plugin I wrote. It's driver DLL
depends on another (managed) DLL. When I put this dependent DLL in the
same directory as the plugin, it can't find it. If I move this
dependent DLL to the root directory of the application it all works
fine. How can I get it to seach the directory that the plugin is in? I
tried using the <probeattribu te in the app.config but without any
luck.

Any direction with either of these problems would greatly be
appreciated!
Try putting this in your App.config and make sure the directory name is
relative to the root of your application (your application must be the root of
the tree and ../../../somedir is not allowed).

<runtime>
<assemblyBindin g xmlns="urn:sche mas-microsoft-com:asm.v1">

<probing privatePath="bi n"/>

</assemblyBinding >
</runtime>

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 13 '06 #2
"Dan Dorey" <da*******@gmai l.comwrote:
In one particular case this dependency is to a C++ DLL called
PF_DTMF_Connect or.dll which in turn is dependent on another C/C++ DLL
in the windows\system3 2 folder.
[Could not load file or assembly
'file:///C:\working\IQ\v 6.0\DTMFTester\ bin\Debug\Plugi ns\Enumeration\ PF_DTMF_Connect or.dll'
or one of its dependencies. The module was expected to contain an
assembly manifest.] :
A normal C++ DLL is not an assembly, so it cannot be loaded by
Assembly.LoadFr om(). If you use it via P/Invoke, it will be loaded
automatically.
My second question relates to another plugin I wrote. It's driver DLL
depends on another (managed) DLL. When I put this dependent DLL in the
same directory as the plugin, it can't find it. If I move this
dependent DLL to the root directory of the application it all works
fine. How can I get it to seach the directory that the plugin is in? I
tried using the <probeattribu te in the app.config but without any
luck.
You can either create a new AppDomain and use the PrivateBinPath of
AppDomainSetup, or you can use Assembly.LoadFr om and hard-wire a path,
or you can hook up to the AppDomain.Assem blyResolve() event.

-- Barry

--
http://barrkel.blogspot.com/
Jul 13 '06 #3
This is telling you that you are trying to load a non-assembly DLL (not all
DLLs are assemblies). You should use DLL Imports and link directly.
Thanks both of you for your responses. The snippet for the app.config
fixed the problem my second question was addressing. I'm still stuck on
the first one however.

I'll give a bit more detail for the first problem.

I'm dynamically loading only a managed DLL that I wrote called
EnumerationDriv er. It is automatically loading the dependent DLLs for
me under the hood.

EnumerationDriv er.dll (managed -- this is the only one I'm dynamically
loading)
DTMFEngine.dll (managed)
PF_DTMF_Connect or.dll (unmanaged C++)
M_DTMF.dll (unmanaged C/C++ in the windows\system3 2 directory).

EnumerationDriv er.dll --DTMFEngine.dll --PF_DTMF_Connect or.dll -->
M_DTMF.dll

DTMFEngine.dll uses a standard DLL import to access
PF_DTMF_Connect or.dll

Should I be using a different method of dynamically loading my DLLs?

Thanks again,
Dan

Jul 13 '06 #4
Dan Dorey <da*******@gmai l.comwrote:
>
DTMFEngine.dll uses a standard DLL import to access
PF_DTMF_Connect or.dll
The error you posted in your original post clearly shows that .NET is trying
to load the PF_DTMF_Connect or.dll as a .NET assembly rather than linking in
via PInvoke (using DLLImport). Perhaps you are mistakenly loading
PF_DTMF_Connect or.dll rather than DTMFEngine.dll from EnumerationDriv er.dll?
Could it be a simple as an incorrect entry in your configuration file?

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 13 '06 #5
Thomas,

You're absolutely right! This makes a lot more sense to me now. I was
just trying to load every DLL in the directory so of course it would
try to load those ones as well!

Thanks for your help!

Thomas T. Veldhouse wrote:
Dan Dorey <da*******@gmai l.comwrote:

DTMFEngine.dll uses a standard DLL import to access
PF_DTMF_Connect or.dll

The error you posted in your original post clearly shows that .NET is trying
to load the PF_DTMF_Connect or.dll as a .NET assembly rather than linking in
via PInvoke (using DLLImport). Perhaps you are mistakenly loading
PF_DTMF_Connect or.dll rather than DTMFEngine.dll from EnumerationDriv er.dll?
Could it be a simple as an incorrect entry in your configuration file?

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1
Jul 13 '06 #6
Dan Dorey <da*******@gmai l.comwrote:
Thomas,

You're absolutely right! This makes a lot more sense to me now. I was
just trying to load every DLL in the directory so of course it would
try to load those ones as well!

Thanks for your help!
You are welcome! I wish I had known this group had an active participation a
long while back.

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 13 '06 #7

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

Similar topics

2
2865
by: Johann Blake | last post by:
I can hardly believe I'm the first one to report this, but having gone through the newsgroup, it appears that way. I would like to open a solution in the VS.NET IDE that consists of multiple DLLs and a test application (an .EXE). The .EXE is my startup application. All the DLLs are shared components. This means that they contain a key and are stored in the GAC. When I go to run the test application in the IDE, it will not execute...
1
21171
by: Jon Davis | last post by:
I'm trying to access my application files for a plug-in I'm building for a third party application. I have an assembly with several dependency assemblies. The dependency assemblies are in the same directory as the assembly. d:\dev\cs\MyApp\bin\Release\MyApp.dll d:\dev\cs\MyApp\bin\Release\Dependency1.dll d:\dev\cs\MyApp\bin\Release\Dependency2.dll
1
2936
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?
2
1309
by: Willy | last post by:
I need to create an object from a dll which will be based on user input. The dll is a VB.NET dll. How do I create this dynamically? Will I need to put the dll in the GAC?
0
1090
by: Konstantin Gonikman | last post by:
Hi, I just played around with WebResource and embeding .js and .css files into my dlls. All works perfectly except following: As I try to embed any WebResources in assemblies that are loaded dynamically from my code (with Assembly.Load() ), WebResource.axd fails to find these resources (FileNotFoundException). Any ideas of work-around?....
2
1433
by: David McCallum | last post by:
I'm not infront of my computer just now, but I seem to remember when my app is being executed the output console shows all the DLLs being loaded. Is there anyway to load these DLLs as and when required? TIA David McCallum
2
5119
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 = Windows Forms class B = a singleton hosted within A. B is responsible for dynamically loading classes X, Y, and Z.
20
4309
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. How can I dynamically load a LIB file and access all its functions? Surely someone has solved similar task? My intention is to use a Forth system for programming the controller,
8
3141
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...
0
9727
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
10982
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
10645
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
10706
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
7053
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
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
4524
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
4116
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3160
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.