Link to home
Start Free TrialLog in
Avatar of VirtueTech
VirtueTech

asked on

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;

   [DllImport("client.dll")]
   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
   [DllImport("c:\\Inetpub\\wwwroot\\WebApplication1\\client.dll")]
- 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
Avatar of surehtoday
surehtoday

James,

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:
http://samples.gotdotnet.com/quickstart/howto/doc/Interop/Building_Samples_NET2COM.aspx
http://samples.gotdotnet.com/quickstart/howto/doc/Interop/TestClient_1.aspx
Avatar of VirtueTech

ASKER

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\
bin\hikclient.dll"

I got this in return:
LoadLibrary("c:\Inetpub\wwwroot\WebApplication1\
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?
[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?
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?
ASKER CERTIFIED SOLUTION
Avatar of surehtoday
surehtoday

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?