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  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:\\ZAUtil.dll).

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

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?

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 security or what.

Monday, June 28, 2004

Ok I finally figured out the problem.  The 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. 

Monday, June 28, 2004

*  Recent Topics

*  Fog Creek Home