none
Where do GAC installed assemblies look for libraries that are referenced with [DLLImport(....)] ? RRS feed

  • Question

  • Hi everyone,

    my problem is a bit complicated so i have to speak verbosely.
    I'm writing a class library in C# which - among others - references Zoom.Net.dll and Zoom.Net.YazSharp.dll ( that's a C# wrapper available on SourceForge for an object model which retrieves bibliographic metadata via the Z39.50 network protocoll). I had to disassemble and reassemble them with a keyfile because they were not strong name signed, but my assembly needs to be in the GAC.
    One of the 2 files reference an external module called yaz.dll (which i think is unmanaged code). When i parse the assembly in the .NET Reflector i can see several [DLLImport("yaz",....)] - like declared methods. Both Zoom dlls and my class library that uses their objects are instaleld in the GAC now, and everytime i call one of the methods that call a method from the yaz.dll i get a System.DllNotFoundException "Unable to load DLL 'yaz'".
    All this is running in a WSS 3.0 environment ( i use the libraries in a webpart ). So i copied the yaz.dll to "c:\windows\system32\" "c:\inetpub\wwwroot\wss\VirtualDirectories\80\bin" , "c:\program files\common files\microsoft shared\web server extensions\12\IASPI" and of course to the \bin folder of the VS project. But still the dll can not be found.

    So can anyone tell me where i should copy the yaz.dll? I can't think of any other possible locations.

    Thanks in advance!

    Tuesday, October 27, 2009 4:04 PM

Answers

  • The yaz.dll module has its own dependencies.  This doc page documents iconv.dll and libxml2.dll as dependencies, there might be others.  A DLL cannot be loaded if its dependencies cannot be found.  Please use the support provided by the open source group for additional questions.

    Hans Passant.
    • Marked as answer by N_F Wednesday, October 28, 2009 12:20 PM
    Tuesday, October 27, 2009 5:26 PM
    Moderator

All replies

  • When you use [DLLImport], the dll being loaded is loaded using the standard Dynamic Link Library Search order in Windows.

    In general, I'd avoid installing a DLL into the GAC that is loading unmanaged code.  If you do so, you most likely need to put the unmanaged DLL into the system folder, since that is likely the only folder that will always be available no matter what application tries to use the GAC'ed assembly.
    Reed Copsey, Jr. - http://reedcopsey.com
    Tuesday, October 27, 2009 4:50 PM
    Moderator
  • The yaz.dll module has its own dependencies.  This doc page documents iconv.dll and libxml2.dll as dependencies, there might be others.  A DLL cannot be loaded if its dependencies cannot be found.  Please use the support provided by the open source group for additional questions.

    Hans Passant.
    • Marked as answer by N_F Wednesday, October 28, 2009 12:20 PM
    Tuesday, October 27, 2009 5:26 PM
    Moderator
  • Thanks, that was the problem. In addition msvcrt71.dll was missing. I was under the assumption that the debugger would tell me if a specific dependancy is missing because i'm used to that from c++.
    Wednesday, October 28, 2009 12:22 PM