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

asp.net and dllimport

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, lets say the web
service dlls reside in c:\<myservice path>. The imported dlls are in
c:\<myservice path>\importeddlls. Therefore, the DllIImport declaration
looks like this:
[DllImport(@"importeddlls\import1.dll", EntryPont="functionName")]

This is working fine for production. But when I try to debug, it can't find
the dll. I did notice that the executing assembly location would be like:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\myservicevdir\7e128e00\3fa09952\assembly\dl3 \48f477a3\2aa7278e_0628c901\import1.DLL

If it is looking there for the sub directory importeddlls, it won't find it
which would explain the error. If this is the case, how do I get it to find
the dll? I'm sure that I've done this previously when I've attached to a
service on a remote machine and I'm pretty sure that I've done it with the
service on my own machine, but now something has changed it the dll's can't
be found. I might have just changed a setting that messed it up, but not
sure.

Any ideas?
Oct 7 '08 #1
1 8422
Hi Larry,

From your description, I understand that one of your ASP.NET webservice
application use some managed and unmanaged dlls(managed assembly use
unmanged ones for PINVOKE). However, at debugging time, the application
will report error that cannot load the unmanaged dll, correct?

Based on my experience, this is a common issues which is caused by the
shadow copy feature of .net application. While the ASP.NET application will
always shadow copy managed asembly to temporary folder(but not for the
unmanaged dlls).

And there used to be many other guys reporting the same issue(even when
running the application without debugging) which use managed and unmanaged
dlls together.

So far there are several means which can help resolve the unmanaged dll's
probing/locating issue:
#- Pre-load the native dll using LoadLibrary (make an early call to
LoadLibrary([full path to the DLL]), so that the DLL is already correctly
loaded later when it is needed.

http://blogs.msdn.com/junfeng/archiv...14/181932.aspx
http://blogs.msdn.com/junfeng/archiv...20/599434.aspx)

this will require us to change code.
#Disable shadow copying (<hostingEnvironment shadowCopyBinAssemblies="false
/>), so the assembly runs directly from bin (with the obvious rawback that
it's locked until the app shuts down)
#Put the assembly somewhere on the system PATH (environment variable) such
as system32 folder. Or you can manually add your own folder(contains those
unamanged dlls ) to the PATH environment variable.
and here is a web forum thread discussing on the similar issue:

http://forums.asp.net/p/939729/1121085.aspx#1121085
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Larry" <ad*****@newsgroup.nospam>
Subject: asp.net and dllimport
Date: Mon, 6 Oct 2008 22:26:14 -0600
>
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, lets say the web
service dlls reside in c:\<myservice path>. The imported dlls are in
c:\<myservice path>\importeddlls. Therefore, the DllIImport declaration
looks like this:
[DllImport(@"importeddlls\import1.dll", EntryPont="functionName")]

This is working fine for production. But when I try to debug, it can't
find
>the dll. I did notice that the executing assembly location would be like:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Tem porary ASP.NET
Files\myservicevdir\7e128e00\3fa09952\assembly\dl 3\48f477a3\2aa7278e_0628c9
01\import1.DLL
>
If it is looking there for the sub directory importeddlls, it won't find
it
>which would explain the error. If this is the case, how do I get it to
find
>the dll? I'm sure that I've done this previously when I've attached to a
service on a remote machine and I'm pretty sure that I've done it with the
service on my own machine, but now something has changed it the dll's
can't
>be found. I might have just changed a setting that messed it up, but not
sure.

Any ideas?
Oct 7 '08 #2

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

Similar topics

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...
6
by: Tim Mulholland | last post by:
Whats the correct C# datatype (or marshalling function or something) to use when you're importing a function that has a signature similar to char* FuncA(char c) ? Assuming you know that...
9
by: Ole Christensen | last post by:
I'm trying to make a sort of conditional compilation in my C# code because my app is intended to run on both a Pocket PC and on a normal desktop PC. My code uses a call to an API function that on...
3
by: Mark Jerde | last post by:
I'm sill learning VS .NET 2003, not an expert yet. I'm calling an unmanaged C++ DLL from C# using . When the whole project is done I will be calling a total of 5 C++ DLLs from C#. All the DLLs...
1
by: Brian Anderson | last post by:
Hello, I have a native, C++ console app that uses ~26MB of RAM when it runs. It uses quite a lot of RAM to make some math but will never xceed 26MB. Now I've made a dll out of this code and...
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...
2
by: Ed | last post by:
Hello, dear all, I often see these two import usage in the code. Both are the interface to use the Dll library. I think they are the same. Normally P/Invoke means using the to import the dll....
1
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built...
9
by: jjones7947 | last post by:
Am doing a JNI wrap on a C++ API, am using VC7 and Eclipse. In preparation, I created a C++ executable which mimicked the flow of the JNI, i.e. a driver file which called methods in file with methods...
1
by: elke | last post by:
Hi, I want to use an unmanaged dll in C# .net and I'm having some troubles witch a function that should return an array. I'm new at this, so I don't know what I'm doing wrong. Here is some...
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: 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
marktang
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,...
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...
0
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...

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.