Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

calling C DLL from .NET.

I am trying to call a C DLL from C# which is being run in ASP.net.  In fact this is the only reason I am using .NET at all.  No matter what I try I get the following error:

Exception Details: System.DllNotFoundException: Unable to load DLL (e:\license.net\ZAUtil.dll).

I even tried putting the path explicitly in my C# call such as:

[DllImport("e:\\path\\myfuncs.dll")]
public static extern void foo(int bar);

I'm starting to think that the exception is named incorrectly.  That the real problem is that the run time can not find the exported function, not that the dll isn't found...

My first question is what is the path ASP.NET searches when looking for DLLs?

christopher baus.net
Monday, June 28, 2004

Have you checked the permissions on the DLL?

Greg Hurlman
Monday, June 28, 2004

It is set to full control everybody. 

This is driving me up the wall.  I'm not sure if it is a problem with asp.net security or what.

christopher baus.net
Monday, June 28, 2004

Ok I finally figured out the problem.  The asp.net exception was quite vague.  It actually wasn't that the loader couldn't find the dll I was trying to call, it was that the loader couldn't find another DLL that the first one depended on.  What I did was run it in a console app, and I got a different exception which lead me to the problem.

Whew.  I think I have all the technical pieces in place to get the project done now. 

christopher baus.net
Monday, June 28, 2004

*  Recent Topics

*  Fog Creek Home