473,785 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem finding DLL

I am trying to use unmanaged DLLs within managed code. My approach is
to create a managed DLL with wrapper functions for my unmanaged
functions. The unmanaged functions come from an unmanaged DLL.

I can successfully build my managed DLL and use it from managed code.
However, at runtime the code cannot find the unmanaged DLL. I've tried
putting the unmanaged DLL in the same directory as the code is running
from, in C:\Windows\Syst em32, and a few other places - no luck, I
always get an error indicating that the unmanaged DLL cannot be found.

Here is what I do in my managed DLL to access functions in the
unmanaged DLL:

using namespace System::Runtime ::InteropServic es;

[DllImport("ADT_ API_L1", EntryPoint="ADT _L1_Initialize" )]
extern "C" unsigned int ADT_L1_Initiali ze(unsigned int dev_num,
char *filename);

The unmanaged DLL is "ADT_API_L1.dll ". In the code for the managed DLL
I also define a namespace and classes with member functions that call
unmanaged functions like "ADT_L1_Initial ize" - I left this out to keep
this as uncluttered as possible.
>From my managed CLR application I include the managed DLL as a
reference and I can see my namespace, classes, etc. The managed
application compiles without error, but when I run the program it
chokes and dies, giving an error that it cannot load the DLL
(System.DllNotF oundException).

I'm sure there is something simple and stupid that I am missing. Can
anybody here set me straight?

Nov 17 '06 #1
2 1023
I can successfully build my managed DLL and use it from managed code.
However, at runtime the code cannot find the unmanaged DLL. I've tried
putting the unmanaged DLL in the same directory as the code is running
from, in C:\Windows\Syst em32, and a few other places - no luck, I
always get an error indicating that the unmanaged DLL cannot be found.
The DLLs get loaded at runtime.
To make sure that you native dll is found
put it alongside the assembly in which it is imported or install it on your
disk somewhere, and add the containing folder in your path variable.

Now, there are 2 things to keep in mind:
- putting stuff in the system32 directory is frowned upon. you generally
don't want to do this to avoid DLL hell.
- be sure that your native DLL can also resolve its dll dependencies. it
will fail to load if one of its dependencies cannot be found (like e.g. the
VC runtime dlls)

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Nov 18 '06 #2

Bruno,

I figured out my problem (I was doing something stupid), but thanks for
your response.
I do have another question related to DLLs, but I put it in a new post.

Thanks again,
Rich

Nov 18 '06 #3

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

Similar topics

8
2074
by: Dave | last post by:
Hi all, I've been trying to figure this out for the last day and a half and it has me stumped. I've got a web application that I wrote that keeps track of trading cards I own, and I'm moving it from an Access 2000 database to a SQL Server 2000 database. Everything worked perfectly in Access, but I'm having trouble getting data to display in SQL Server. For reference, here's the query. It's big and nasty, but I thought
7
3190
by: addled | last post by:
Hi there, after reading posts here for a few months, I've built the courage to see if someone can see where I"m going wrong in the webpage I've been working on. In particular the horizontal nav bar accross the top of the page. viewd here http://foundations.port5.com/currprojects/babylon.html I am running win XP and have tested in both Avant (MSIE) and Opera 7.23 the result is a different problem in each.
117
7268
by: Peter Olcott | last post by:
www.halting-problem.com
2
1977
by: John Jumper | last post by:
I am using an XmlDataSource in VS2005Beta1 and setting the TransformFile property in my ASCX and it is finding both files. However, the resulting data does not contain any of the sub nodes of the generated document. I have tested my XSL by viewing the generated XML and it properly transforms the DataFile in the UI editor for the XSL. I have verified the XmlDataSource is finding the DataFile by removing the TransformFile property which...
4
2181
by: | last post by:
I am stuck in a situation and I do believe that this should work, but it doesn't. I have a unmanaged dll, that uses MFC. This works great. Now I recompile the unmanaged dll so it contains mixed mode managed/unmanaged code, but only use unmanaged code, but this gives a error the moment I want to display a MFC dialog box: Something like unreferenced object,... during runtime.
6
1425
by: Jared Turley | last post by:
I am currently having an issue with an ASP.NET page not finding the class library located in the application's /bin directory. The page recognizes the compiled .dll class when running on my development machine (IIS6/WinXP Pro) but when uploading to the web host the simple error message of "Type Not Defined" is returned. I have since opened an incident with the web host support personnel but they claim that all they have is the standard...
1
3185
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during EventList_ItemCreated (below the html), but it's always <undefined value> (null). Everything else works fine. Eventually I need to set the value of the label depending up the Count of the DataView "dvDiscount". For now I'll settle for just finding the damn...
6
1676
by: Florian Lindner | last post by:
Hello, I have these class declarations class CBauteil { private: int m_iNumber; int m_iWeight; public: int getNumber(); void setNumber(int);
1
1363
by: Empyrean | last post by:
I'm attempting to make my first program that involves file input, but I'm running into problems finding the .txt file. I placed the file inside the same folder as the rest of the project, but it still doesn't seem to be finding it. Am I doing something wrong? try { in = new Scanner(new File("File Reading.txt")); String test = in.nextLine();
1
1362
by: avik1612 | last post by:
Hi, I have created a program to find text files in a particular directory or folder. and to find a particular word in that files i finding it difficult to put the list in an array and finding the words I have pasted the code below
0
9645
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, 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...
0
10329
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
9950
tracyyun
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...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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
5381
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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 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.