Unable to load DLL (client.dll) - My ASP.NET 1.1 C# application having problems on 2003 but not on XP

Posted on 2006-04-05
Last Modified: 2008-01-09
Hello everyone,

I developed my C# ASP.NET (Framework 1.1) application on my Windows XP Pro computer. I was able to use the follwoing to import a DLL and use its functionality with no problems. I was able to run the application on my computer without getting the "Unable to load DLL (client.dll)" message.

However when I uploaded the application to our Windows Server 2003 IIS server it gave me the following message:
Unable to load DLL (client.dll)

The calls I'm using are as follows: (I have three of these...but I'll only show one here to save space)
   using System.Runtime.InteropServices;

   public static extern int MP4_ClientGetServerChanNum([MarshalAs(UnmanagedType.LPStr)]  string  m_sIPAddress);

So since I've been getting the error "Unable to load DLL (client.dll)" on my Windows Server 2003 I've tried the following remedies with no luck: NOTHING BELOW WORKED FOR ME:
- Tried hard coding  the path of the DLL into the DLLImport call
- Tried to add the DLL to the applications BIN directory
- Tried to add the DLL to the applications BIN directory AND point the path of the DllImport to the BIN directory
- Tried to set the permissions on the "client.dll" file so that my IIS user could execute it. I really thought this would do it but it didn't work.
- Added the "client.dll" file to my C:\Windows\System32; and C:\Windows; direcotries and set the permissions for the IIS user to execute them. I actually didn't try hard coding the path to the above windows directories ...will have to try that after this post.
- Tried to change my environment variables. Set PATH to where the application lives c:\Inetpub\wwwroot\WebApplication1

At this point I am desperate and would appreciate the help. I will offer 2000 points for this question if someone can help me. I'll settle that with the person who answers.

Any comments and/or points in the right direction are appreciated.

-- James
Question by:VirtueTech
    LVL 1

    Expert Comment


    It seems client.dll is not a .net dll.

    So first register the compoent in the client machine (2003) with regsvr32 command, if am right.

    Hope this helps.

    LVL 6

    Expert Comment

    Is client.dll a regular DLL or a COM+ DLL?

    If it is a regular Win32 DLL, you're using the right method. But it seems like it isn't.

    If it is a COM+ DLL, you'd need to first run regsvr32.exe as surehtoday points out. Afterwards, you'd need to use tlbimp to generate a wrapper around the DLL. And after all this, you can call the classes in the DLL just as if it was made in .NET (I.e. you don't have to do the DllImport manually).
    Check out these articles for more detailed instructions:

    Author Comment

    First off thanks for your replies. They are making me very optimistic that this will work. Excuse this newb, but I'm not sure if the DLL is WIN32 or COM+. Is there a simple way to find out?

    I tried running "regsvr32" form command prompt like so:

    C:\Inetpub\wwwroot\WebApplication1> regsvr32 "c:\Inetpub\wwwroot\WebApplication1\

    I got this in return:
    bin\hikclient.dll") failed - The specified module could not be found.

    - I checked the permissions on the file...they look fine. The administrator is the owner and has privileges.
    - The file does exist in that path

    Any ideas what I'm doing wrong?

    Author Comment

    [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
    static extern IntPtr LoadLibrary(string lpFileName);

    I run that in the beginning of my code. Is it the same thing that "regsvr32" is trying to do when I run it from command line?

    Author Comment

    by:VirtueTech it wrong to assume the DLL is a Win32 DLL because I was able to make it work on my Windows XP Pro development machine?
    LVL 1

    Accepted Solution

    Hi Virtue,

    The reason for your curent error may be, some dependency dlls may not available in the target machine.

    try to check what are dlls referenced my your component.

    Author Comment

    I love you. I mean I really love you. Thank you so much. I can't begin to explain how huge that was.

    Upon opening the dll in "Dependancy Walker" it showed that it was looking for a DLL that came with the product. Little did I know they were dependant on each other.

    I appreciate it so much. I'd really like to give you more points. Maybe a question just to give points?


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now