all groups > dotnet clr > december 2003 >
You're in the

dotnet clr

group:

GAC: Installing DLL which depends on EXE



GAC: Installing DLL which depends on EXE Claus Brod
12/12/2003 2:54:30 AM
dotnet clr: Hi all,

first of all, I'm a .NET newbie, and while I have done some
basic research and browsing, chances are that my question
is trivial and I should simply RTFM; I apologize. Also, if
this is not the right newsgroup, let me know.

We want to add a .NET wrapper on an existing C++
application. The way we plan to do this is to write a .NET
DLL (let's call it wrapper.dll) which exposes some of the
functionality in the application EXE (for this discussion,
bigapp.exe) to .NET/COM clients. bigapp.exe is written in
unmanaged C++ (and no, we do not want to make it managed),
while wrapper.dll is managed C++. The wrapper DLL calls
into the EXE using the "it just works" approach.

All this "just works" fine except for one significant
problem: It seems we need to push wrapper.dll to the GAC to
make its services globally accessible. However, wrapper.dll
links against bigapp.exe (direct symbol references), so
when a client "instantiates" the DLL, the DLL needs to find
the EXE, or it will fail to load.

The trivial approach is to push bigapp.exe and everything
associated with it to the GAC as well. However, that would
be a HUGE package of several hundreds of megabytes in size.
Also, since bigapp.exe is usually started as a stand-alone
app, the more natural location for it is somewhere in the
"Program Files" folder anyway.

The only way we could make this work so far was by adding
the installation path of bigapp.exe to the PATH environment
variable. However, this is a hack and almost certain to
fail on customer systems; the first system we tried this on
already had a PATH longer than 1024 bytes, so any paths
added to the end of PATH are simply ignored...

I have seen references to modifying the assembly manager's
probing algorithm, but AFAIK the assembly manager only
allows to add search directories in the GAC itself, not
outside of the GAC.

Any ideas or hints most welcome. Or maybe the whole
approach is crazy?

Thanks!

Claus
RE: GAC: Installing DLL which depends on EXE shawnfa NO[at]SPAM online.microsoft.com (
1/20/2004 8:18:11 PM
Hi Claus,

Unfortunately this approach won't work for you. Even if you decided that you'd take the size hit by GACing bigapp.exe, you'd find that it is
actually not possible to place unmanaged code into the GAC. Do you anticipate having applications that you do not distribute link against your
.dll? If not, I might recommend adding a .config file to each application that requires your new .dll and telling fusion where to look for it. This is
accomplished through the use of either a <probing> tag or a <codeBase> tag. I would recommend the following references:

* Specifying an Assembly's Location (details on <probing> and <codeBase>): http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpguide/html/cpconspecifyingassemblyslocation.asp

* How the Runtime Locates Assemblies: http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpguide/html/cpconhowruntimelocatesassemblies.asp

-Shawn
http://blogs.msdn.com/shawnfa

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they
originated.
--------------------
[quoted text, click to view]

AddThis Social Bookmark Button