473,385 Members | 1,464 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.

DllImport path issue

I'm sure I'm missing something basic.
I have an class library that uses an unmanaged dll.

Let's say the class library is called "CL1.dll" and is located at:
[c:\temp\CL\CL1.dll]
and the unmanaged dll is called "UM.dll" and is located at [c:\temp\UM.dll]

For my DllImport attribute I was using [DllImport("c:\temp\UM.dll")] and
this worked.

Now I want to setup my installer so I can deploy this app and I realize that
I can't hard code the path like that. So I tried copying [UM.dll] to
[c:\temp\CL\] thinking that if it was in the same directory as CL1.dll it
would find it if I did this: [DllImport("UM.dll")]

no luck. Throws an exception saying it can't find it.

Then I thought I might still need to supply the full path, so I tried using
the Assembly class to get the executing path oc CL1.dll. This doesn't work
because DllImport needs a const string.
so.. how do I do this? Seems like it should be easy, but it's beating me...
:(

Thanks,
Steve
Mar 1 '06 #1
6 19887
>so.. how do I do this? Seems like it should be easy, but it's beating me...

Place it in the directory of the application that consumes the class
library, or in some other directory searched by LoadLibrary. See

http://msdn.microsoft.com/library/en...arch_order.asp
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 1 '06 #2

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:eM*************@tk2msftngp13.phx.gbl...
so.. how do I do this? Seems like it should be easy, but it's beating
me...
Place it in the directory of the application that consumes the class
library, or in some other directory searched by LoadLibrary. See

http://msdn.microsoft.com/library/en...arch_order.asp


HI,
Mattias

I tried that and I'm still getting the error. My Exe that consumed the
managed dll, the managed dll and the unmanaged dll that it wraps are all in
the same folder. I looked over the link that you send me, but I don't see a
solution in there for my situation.

Anything else that I can try?

-Steve



Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Mar 1 '06 #3
It was another assembly that wasn't loading correctly. It's tough to find
these types of probs in release mode!

Anyway, thanks again for the help.
-Steve
"Steve" <ss*@sss.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:eM*************@tk2msftngp13.phx.gbl...
>so.. how do I do this? Seems like it should be easy, but it's beating
>me...


Place it in the directory of the application that consumes the class
library, or in some other directory searched by LoadLibrary. See

http://msdn.microsoft.com/library/en...arch_order.asp


HI,
Mattias

I tried that and I'm still getting the error. My Exe that consumed the
managed dll, the managed dll and the unmanaged dll that it wraps are all
in the same folder. I looked over the link that you send me, but I don't
see a solution in there for my situation.

Anything else that I can try?

-Steve



Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Mar 1 '06 #4

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:eM*************@tk2msftngp13.phx.gbl...
so.. how do I do this? Seems like it should be easy, but it's beating
me...


Place it in the directory of the application that consumes the class
library, or in some other directory searched by LoadLibrary. See

http://msdn.microsoft.com/library/en...arch_order.asp


Well, I spoke too soon. This is still very much broken. I am trying to run
my application in release mode on another machine. When it crashes I click
the 'debug' and then see the exception:

<exception>
Failed to load module from assembly FETProgrammerModule, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Error was:
Failed to load module from assembly FETProgrammerModule, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Error was:
Unable to load DLL 'msp430.dll': The specified procedure could not be found.
(Exception from HRESULT: 0x8007007F)
</exception>
All of my assemblies are in a single folder.
This is so frustrating, I don't understand why it won't search in the folder
it's being consumed from??

Please, anyone have any other tips for me?
Mar 2 '06 #5
Are there any other dependencies that the unmanaged DLL is expecting that are
not present on the other machine? You can use DumpBin.exe in the VS2003
command prompt to help you with P/Invoke.

http://msdn.microsoft.com/library/de...binpinvoke.asp
"Steve" wrote:

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:eM*************@tk2msftngp13.phx.gbl...
so.. how do I do this? Seems like it should be easy, but it's beating
me...


Place it in the directory of the application that consumes the class
library, or in some other directory searched by LoadLibrary. See

http://msdn.microsoft.com/library/en...arch_order.asp


Well, I spoke too soon. This is still very much broken. I am trying to run
my application in release mode on another machine. When it crashes I click
the 'debug' and then see the exception:

<exception>
Failed to load module from assembly FETProgrammerModule, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Error was:
Failed to load module from assembly FETProgrammerModule, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Error was:
Unable to load DLL 'msp430.dll': The specified procedure could not be found.
(Exception from HRESULT: 0x8007007F)
</exception>
All of my assemblies are in a single folder.
This is so frustrating, I don't understand why it won't search in the folder
it's being consumed from??

Please, anyone have any other tips for me?

Mar 2 '06 #6
Yes, that appears to be the real problem. The unmanaged DLL did need
another DLL that I wasn't supplying a path to.
Thanks for the idea, it worked out well for me.

Have a great day,
Steve
"rmacias" <rm*****@newsgroup.nospam> wrote in message
news:C4**********************************@microsof t.com...
Are there any other dependencies that the unmanaged DLL is expecting that
are
not present on the other machine? You can use DumpBin.exe in the VS2003
command prompt to help you with P/Invoke.

http://msdn.microsoft.com/library/de...binpinvoke.asp
"Steve" wrote:

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:eM*************@tk2msftngp13.phx.gbl...
> >so.. how do I do this? Seems like it should be easy, but it's beating
> >me...
>
> Place it in the directory of the application that consumes the class
> library, or in some other directory searched by LoadLibrary. See
>
> http://msdn.microsoft.com/library/en...arch_order.asp
>
>


Well, I spoke too soon. This is still very much broken. I am trying to
run
my application in release mode on another machine. When it crashes I
click
the 'debug' and then see the exception:

<exception>
Failed to load module from assembly FETProgrammerModule, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Error was:
Failed to load module from assembly FETProgrammerModule, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null. Error was:
Unable to load DLL 'msp430.dll': The specified procedure could not be
found.
(Exception from HRESULT: 0x8007007F)
</exception>
All of my assemblies are in a single folder.
This is so frustrating, I don't understand why it won't search in the
folder
it's being consumed from??

Please, anyone have any other tips for me?

Mar 2 '06 #7

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

Similar topics

4
by: Michael Tissington | last post by:
I have a C# function that calls into a C++ DLL I have placed the DLL in the 'bin' folder of my asp.net project I'm using something like However when I try to call the function I'm getting...
2
by: pnp | last post by:
Hi all, i'm having a problem using DllImport with Win98. It works just fine with XP & 2000 but in 98 it prompts: "Unable to find xxxxx.dll". Any ideas? error is: System.DllNotFoundException:...
1
by: Irfan | last post by:
Hi, I tried the same, but did not get any such error/exception. Here's my path to the win32 DLL that I reference in my C# code with VS.NET 2003 and .NET framework 1.1 public static extern...
2
by: sonyram | last post by:
As our application design requires us to use one of the validation API engine which was written on C(so basically all I have is a dll) and I tested calling the functions using small windows...
2
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no...
10
by: A_StClaire_ | last post by:
hi guys, I am working on a C# app that needs to create directories on the fly. security settings enforced by our ISP do not allow us to use the standard .NET calls, so I am forced to resort to...
0
by: chandan | last post by:
Hi All, I have a dll created using vc++(Unmanaged).So when we are using this I have to give to full path of this dll as a parameter of DllImport attribute. The parameter takes only const string...
0
by: chandan | last post by:
Hi All, I have a dll created using vc++(Unmanaged).So when we are using this I have to give to full path of this dll as a parameter of DllImport attribute. The parameter takes only const string...
1
by: Larry | last post by:
I have an asp.net application (C#) that calls a web service that uses several c++ dlls which are loaded with DllImport. I put these dlls in a sub-directory off of the bin directory. For example,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.