Results 1 to 12 of 12

Thread: [RESOLVED] unable to load unmanaged dll

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Resolved [RESOLVED] unable to load unmanaged dll

    I have code to call a DLL that I wrote in C (see end of message). This code has worked fine for months. I reloaded my OS and installed a fresh vs2005 rc and now I'm getting a System.DllNotFoundException. It also says: Unable to load DLL 'copy.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    My DLL is in my working directory just as it was before. My project setup has not changed and the working directory is specified correctly. What could have changed to cause this error?

    Code:
    [DllImport( "copy.dll", CharSet = CharSet.Unicode )]
    public static extern int BackupClose( long hash1, long hash2 );

  2. #2
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: unable to load unmanaged dll

    i guess its your file system has change.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: unable to load unmanaged dll

    According to MSDN,
    If you provide no path, the DLL must be in the current path at run time
    But if as you say the working directory is specificed correctly, then I'm not sure why it doesn't work. You may need to try putting it in the \System32 folder.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Re: unable to load unmanaged dll

    I tried putting a copy everywhere I could think of, including system32.

    This is extremely frustrating.

  5. #5
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: unable to load unmanaged dll

    Does copy.dll reference any other dlls that may have been removed when you reinstalled your OS? If you wrote that dll you probably know, you can also use dependency walker (depends.exe) to check it out.

    Mike

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Re: unable to load unmanaged dll

    Thanks mucho! Depends.exe showed my problem immediately.

    I was surprised to find that my dll depended on another dll. I have no code to load a dll. My link setup referred to a xxx.lib file, which I thought would cause it to link in the code instead of requiring a runtime dll. I didn't even know xxx had a dll. Does this mean that the lib I linked in had a reference to a dll? If so, how was I supposed to know this?

    I have been programming C for a number of years and I thought I understood it all (big mistake).

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    4

    Re: unable to load unmanaged dll

    By the way, I posted this problem on a number of C# discussion boards and I got no help anywhere else and a lot of help here. I think I'll hang out here more often.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: unable to load unmanaged dll

    Welcome to the forums

    If your problem is solved you can let others know by selecting "Mark Thread Resolved" from the "Thread Tools" menu above the 1st post

  9. #9
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Re: [RESOLVED] unable to load unmanaged dll

    Hello All

    I am experiencing similar problem with one of my un-managed C++ DLL.
    This was working fine in Visual Studio 2003 version but gives following error in Visual Studio 2005
    Unable to load DLL 'xxxx.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    I read on this post something related to dependency.
    When i look at the dependency for this it showed system32\Kernel32.dll and system32\OLeAUTO32.dll
    I am calling my DLL from the web page using DLLImport.
    Do i have to reference these system DLLs in my Web Project to make DLLImport call work again ??

    Appreciate any help
    Cheers

  10. #10
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Re: unable to load unmanaged dll

    Quote Originally Posted by mchahn
    By the way, I posted this problem on a number of C# discussion boards and I got no help anywhere else and a lot of help here. I think I'll hang out here more often.

    Please see my post at the end

    Thanks

  11. #11
    New Member
    Join Date
    Apr 2007
    Posts
    1

    Re: [RESOLVED] unable to load unmanaged dll

    Hi guys,

    I am facing same problem. can anybody help me?
    Will i needed to add all depended DLLs as a ref? Both Main DLL and depended DLLs should be on same folder?
    Will i need to register dll with REGSVR32.EXE?

    Thanks,
    Jagdish

  12. #12
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Re: [RESOLVED] unable to load unmanaged dll

    Update the system PATH variable to point to the bin folder where the DLL reside. That should fix it

    Good Luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width