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

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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.

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:
VirtueTechAuthor Commented:
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?
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

VirtueTechAuthor Commented:
[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?
VirtueTechAuthor Commented:
Also...is 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?
Hi Virtue,

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

try http://www.dependencywalker.com/ to check what are dlls referenced my your component.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VirtueTechAuthor Commented:
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?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.