473,396 Members | 2,020 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,396 software developers and data experts.

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 1987
<Ol**********@skyscan.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
GetModuleFileName, 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
GetModuleFileName, 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+unmanaged 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+managed 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**********@skyscan.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::LoadFrom() 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::LoadFrom() 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
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...
0
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...
12
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...
3
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...
2
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...
47
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):...
8
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,...
0
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...
0
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...
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
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
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...
0
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...
0
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...

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.