473,770 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a.exe uses b.dll uses c.dll search path problem

We have this situation:
We have a unmanaged c++ executable located in a certain folder (a.exe)
It loads a mixed mode managed/unmanaged dll using MFC dynamically from a
completely different path (b.dll)
This last dll, uses other pure managed and mixed managed/unmanaged dll's
that uses MFC. (c.dll, d.dll,...)

What works is a.exe loading b.dll.
But once I want to use a functions in c.dll I get an exception indicating
that c.dll is not found. :-(

The off thing is that this c.dll is right there where I put b.dll, I even
moved to the location of a.dll, and put in the GAC.
What works sometimes is, if I put c.dll and d.dll into the GAC, but not
always.

I also set the current directory dynamically but to no avail. :-(

Anyone have a clue what goes wrong?
Nov 17 '05 #1
5 2009
<Ol**********@s kyscan.be> wrote:
We have this situation:
We have a unmanaged c++ executable located in a certain folder (a.exe)
It loads a mixed mode managed/unmanaged dll using MFC dynamically from a
completely different path (b.dll)
This last dll, uses other pure managed and mixed managed/unmanaged dll's
that uses MFC. (c.dll, d.dll,...)

What works is a.exe loading b.dll.
But once I want to use a functions in c.dll I get an exception indicating
that c.dll is not found. :-(

The off thing is that this c.dll is right there where I put b.dll, I even
moved to the location of a.dll, and put in the GAC.
What works sometimes is, if I put c.dll and d.dll into the GAC, but not
always.

I also set the current directory dynamically but to no avail. :-(

Anyone have a clue what goes wrong?


See this for the DLL search order:

LoadLibraryEx
http://msdn.microsoft.com/library/de...dlibraryex.asp

Your best bet is to put all the DLLs into the directory containing a.exe.
You could also reference them with absolute paths with the help of
GetModuleFileNa me, e.g. using it on the b.dll HMODULE and replacing the
filename (b.dll) part with c.dll.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2
> Your best bet is to put all the DLLs into the directory containing a.exe.
You could also reference them with absolute paths with the help of
GetModuleFileNa me, e.g. using it on the b.dll HMODULE and replacing the
filename (b.dll) part with c.dll.

Can you give more details in this?
b.dll is a managed+unmanag ed dll that exposes unmanaged funtions to
unmanaged a.exe, loaded dynamically.
But c.dll is a managed dll that is used in b.dll. And c.dll is going to load
unmanaged+manag ed d.dll automatically.

I only have source access to b.dll.

It is hard to put this into the same location of the exe, since it is
intended as plugin for a.exe and mutiple variations might exist of that dll
name.
The goal is to install this somewhere (maybe other drive) and then let the
a.exe load it dynamically.

But thanks for your tip.
Olaf Baeyens


Nov 17 '05 #3
> Your best bet is to put all the DLLs into the directory containing a.exe.

This seems to work great.
But I still want to install this somewhere else because it is supposed to be
a plugin and must be installed in a separate folder.



Nov 17 '05 #4
<Ol**********@s kyscan.be> wrote in message
news:41******** **************@ news.skynet.be. ..
This seems to work great.
But I still want to install this somewhere else because it is supposed to be a plugin and must be installed in a separate folder.


This is the kind of question that causes my head to hurt, trying to consider
both the managed and unmanaged rules. So take what follows as idle
speculation ...

I'm not sure about this but it may be best to split the the managed and
unmanaged code so you can load the managed and unmanaged components
separately; perhaps using Assembly::LoadF rom() or some such.

Also, if you are using XP/SP1 check the docs for SetDllDirectory () which
causes the specified directory to be bumped (almost) up to the top of the
search list, right behind the current directory that Doug suggested.

Regards,
Will

Nov 17 '05 #5
> > This seems to work great.
But I still want to install this somewhere else because it is supposed
to be
a plugin and must be installed in a separate folder.
This is the kind of question that causes my head to hurt, trying to

consider both the managed and unmanaged rules. So take what follows as idle
speculation ...
Any idea might put me a step closer to solving the problem. :-)
This problem is the only problem that stays between me and writing code
fast.
The learning curve of .NET is huge (security things), but it is worth
learning it.

At this point putting the dll's in the GAC solves the problem.
Also installing it at the location of the executable that calls them also
works.
I'm not sure about this but it may be best to split the the managed and
unmanaged code so you can load the managed and unmanaged components
separately; perhaps using Assembly::LoadF rom() or some such.
I am experimenting with this right now.
But so far, no good result, even when I use absolute paths.
Or force a current directory.

It could be nice if I could enforce some base folder for the dll.
I know that there exist something like AppDomain? But I am still trying to
understand how that works.
Also, if you are using XP/SP1 check the docs for SetDllDirectory () which
causes the specified directory to be bumped (almost) up to the top of the
search list, right behind the current directory that Doug suggested.

This is a good clue.
But it must also work on Win2000.

But thanks for the tip, I really appreciate it.
Nov 17 '05 #6

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

Similar topics

7
2674
by: Andrei Ivanov | last post by:
This happend again, but now, postgresql tells me where it happens: pg_dump: SQL command failed pg_dump: Error message from server: ERROR: did not find '}' at end of input node pg_dump: The command was: select (select usename from pg_user where usesysid = datdba) as dba, pg_encoding_to_char(encoding) as encoding, datpath from pg_database where datname = 'dc' pg_dumpall: pg_dump failed on database "dc", exiting
0
1096
by: Hriday | last post by:
Hi there, I am working on a web application in ASP.NET My web server and AD machine are in the same domain but located on diffrent phisical machine, I am not able to search user's info by the following code if I pass only path as parameter to DirectoyEntry class. The same code is working if I pass all the three parameter as path,userId and password. but I have to use windows authenticatoin and can't get password from Windows...
12
12800
by: Eric Renken | last post by:
I have an application that I am adding support for plug-ins and I am looking for some help on the best way to handle this. My question has to do with AppDomains and the best way to use them. I have a directory structure like this: MyApp \AddIns \AddIn1 \AddIn2
3
1549
by: linq936 | last post by:
Hi, I always have an impression that for the following semantics: #include <something e.g. #include <stdio.h> Compiler searches it from built-in header search path, on UNIX, it could be /usr/include, /bin/include. And for the following semantics: #include "someting" e.g. #include "mine.h" Compiler searches it according to the -I command option and the built-in search path.
2
1111
by: preeti13 | last post by:
hi friends please help me with my problem i have a code for search application it is searching one record from the data base at a time but i have so many records with that name but its not searching the whole list please help me how i can search the whole list of the same names my code is like this <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="SearchReport.Report" %> <!DOCTYPE html PUBLIC "-//W3C//DTD...
47
3450
by: Henning_Thornblad | last post by:
What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row="" for a in range(156000): row+="a"
8
1564
by: tow | last post by:
I have a python script (part of a django application, if it makes any difference) which is exhibiting the following behaviour: import my_module # succeeds imp.find_module("my_module") # fails, raising ImportError which is completely baffling me. According to sys.path, both should fail; the directory containing my_module is not in sys.path (though the my_module directory itself is). More puzzlingly, printing out my_module.__file__...
0
2194
by: TheClouds | last post by:
Hi everyone This program is using A* search and it supposed to find the shortest path for Pacman in the program as(px,py) or currentCell to catch the ghost in the program as(gx,gy)or goalCell.for computing the heuristic value it should use Manhattan distance method and the formula f (n) = alpha * g(n)+beta * h(n) 1-my problem is that I cant get pacman to move more than 3 cells and after that it start's from the begining and get into an...
0
10781
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
9453
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,...
1
10036
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
9904
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...
1
7451
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
6710
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
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.