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

DLLImport and Unable to Load DLL

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
[DllImport("Keycode.dll", EntryPoint="GenerateKey")]

However when I try to call the function I'm getting an error 'Unable to Load
DLL'

Should I specifiy the path to the dll in the DllImport?
If so - do I specifiy a path relative to the web site or a physical path?

Anything else that could be causing this error?
--
Michael Tissington
Oaklodge Technologies
http://www.oaklodge.com/technology

Nov 15 '05 #1
4 18506
Michael,
Should I specifiy the path to the dll in the DllImport?


See http://www.dotnetinterop.com/faq/?q=LoadLibrary

On the platforms where it's available, you can also call the
SetDllDirectory API.

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

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
Mattias,

Thanks for the LoadLibrary link, however this does not seem to work when
running as an ASP.NET web page.

I guess I need to get the path to the original location of the page and not
the temporary location of the assembly.

--
Michael Tissington
Oaklodge Technologies
http://www.oaklodge.com/technology

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:u8**************@TK2MSFTNGP10.phx.gbl...
Michael,
Should I specifiy the path to the dll in the DllImport?


See http://www.dotnetinterop.com/faq/?q=LoadLibrary

On the platforms where it's available, you can also call the
SetDllDirectory API.

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

Mattias

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

Nov 15 '05 #3

Hi Michael,

When you running in ASP.Net what problem do you get?
May be you can try to use absolute path to see if the problem will
arise.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Michael Tissington" <mi*****@nospam.com>
| References: <un**************@tk2msftngp13.phx.gbl>
<u8**************@TK2MSFTNGP10.phx.gbl>
| Subject: Re: DLLImport and Unable to Load DLL
| Date: Thu, 11 Sep 2003 15:27:12 -0700
| Lines: 36
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <u0**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.languages.c
sharp
| NNTP-Posting-Host: antelope.oaklodge.com 63.67.71.5
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.languages.csharp:184228
microsoft.public.dotnet.framework.aspnet:176211
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Mattias,
|
| Thanks for the LoadLibrary link, however this does not seem to work when
| running as an ASP.NET web page.
|
| I guess I need to get the path to the original location of the page and
not
| the temporary location of the assembly.
|
| --
| Michael Tissington
| Oaklodge Technologies
| http://www.oaklodge.com/technology
|
| "Mattias Sjögren" <ma********************@mvps.org> wrote in message
| news:u8**************@TK2MSFTNGP10.phx.gbl...
| > Michael,
| >
| > >Should I specifiy the path to the dll in the DllImport?
| >
| > See http://www.dotnetinterop.com/faq/?q=LoadLibrary
| >
| > On the platforms where it's available, you can also call the
| > SetDllDirectory API.
| >
| > http://msdn.microsoft.com/library/en...ldirectory.asp
| >
| >
| >
| > Mattias
| >
| > --
| > Mattias Sjögren [MVP] mattias @ mvps.org
| > http://www.msjogren.net/dotnet/
| > Please reply only to the newsgroup.
|
|
|

Nov 15 '05 #4
Thanks - seems that I was chasing a red hering - turns out to be a security
issue on the bin folder ...

--
Michael Tissington
Oaklodge Technologies
http://www.oaklodge.com/technology

"Jeffrey Tan[MSFT]" <v-*****@online.microsoft.com> wrote in message
news:du**************@cpmsftngxa06.phx.gbl...

Hi Michael,

When you running in ASP.Net what problem do you get?
May be you can try to use absolute path to see if the problem will
arise.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Michael Tissington" <mi*****@nospam.com>
| References: <un**************@tk2msftngp13.phx.gbl>
<u8**************@TK2MSFTNGP10.phx.gbl>
| Subject: Re: DLLImport and Unable to Load DLL
| Date: Thu, 11 Sep 2003 15:27:12 -0700
| Lines: 36
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <u0**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.languages.c sharp
| NNTP-Posting-Host: antelope.oaklodge.com 63.67.71.5
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.languages.csharp:184228
microsoft.public.dotnet.framework.aspnet:176211
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Mattias,
|
| Thanks for the LoadLibrary link, however this does not seem to work when
| running as an ASP.NET web page.
|
| I guess I need to get the path to the original location of the page and
not
| the temporary location of the assembly.
|
| --
| Michael Tissington
| Oaklodge Technologies
| http://www.oaklodge.com/technology
|
| "Mattias Sjögren" <ma********************@mvps.org> wrote in message
| news:u8**************@TK2MSFTNGP10.phx.gbl...
| > Michael,
| >
| > >Should I specifiy the path to the dll in the DllImport?
| >
| > See http://www.dotnetinterop.com/faq/?q=LoadLibrary
| >
| > On the platforms where it's available, you can also call the
| > SetDllDirectory API.
| >
| > http://msdn.microsoft.com/library/en...ldirectory.asp | >
| >
| >
| > Mattias
| >
| > --
| > Mattias Sjögren [MVP] mattias @ mvps.org
| > http://www.msjogren.net/dotnet/
| > Please reply only to the newsgroup.
|
|
|

Nov 15 '05 #5

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

Similar topics

1
by: mike | last post by:
I have a form that uses a C++ dll through DLLImport. Then I created a new project and had Form1 inherit the DLL form. I can run it without problem, but I cannot open the derrived form in the...
15
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the...
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:...
2
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: 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...
6
by: Steve | last post by:
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: and the unmanaged dll is called...
1
by: nirbhay | last post by:
Hello All I am experiencing a problem calling one of my un-managed C++ DLL from a Web page This was working fine in Visual Studio 2003 version but gives following error in Visual Studio 2005...
4
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I have my own win app developed in VS C# 2005. This app uses a dll file (I import methods from the library by dllimport attribute). The dll file is provided by another program (let's call it...
1
by: =?Utf-8?B?VHJlY2l1cw==?= | last post by:
Hello, Newsgroupians: I have created an unmanaged DLL using Visual Studio 2005, which was created in Visual C++. I have some functions in the DLL that I am trying to call. When I "dumpbin...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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.