I have the following C# code in my web service:
[DllImport ("CaseAssessment.dll",
CallingConvention=CallingConvention.Cdecl)] public static extern double
add_(double X, double Y );
[WebMethod] public double add (double X, double Y){
return add_(X, Y);
}
When I try to call the add function from my C# SOAP client it comes back and
tells me it (I presume the server) cannot load the DLL. Quite some time ago
someone responded to my query on one of these mailing lists and informed me
that she thought the rules for loading a DLL from a web service included
looking in the current directory (which is not the default directory for
IIS/InetInfo/ASP.NET).
Is this incorrect? How do I load a DLL from a web service with P/Invoke?
Siegfried
Eric Cherng - 25 Jun 2004 22:23 GMT
Siegfried,
An ASP.NET web service running in IIS will typically run under the ASP.NET
user process. In Windows XP or Windows 2000, this user name is typically
MACHINENAME\ASPNET. If you're running in IIS6 on Windows 2003, then it's
NETWORK_SERVICE. You should make sure that user account has the correct
security access to your DLL file. Also try putting your DLL in the \bin
folder of the web service folder.
Eric
> I have the following C# code in my web service:
>
[quoted text clipped - 18 lines]
>
> Siegfried
Siegfried Heintze - 27 Jun 2004 18:22 GMT
Thanks Eric,
I put it in the bin directory that was created by Visual Studio.net when I
deployed the service originally.
I used ftp with an ls -l and determined the protections are the same as the
dll Visual Studio deployed.
Here is my error message:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was
unable to process request. ---> System.DllNotFoundException: Unable to
load DLL (c:\inetpub\heintze\AnalyzeResults\bin\CaseAssessment.dll).
at AnalyzeResults.Service1.addr_(Double& X, Double& Y)
at AnalyzeResults.Service1.addr(Double& X, Double& Y)
--- End of inner exception stack trace ---</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope><br>
> Siegfried,
>
[quoted text clipped - 32 lines]
> >
> > Siegfried
Eric Cherng - 28 Jun 2004 17:37 GMT
Siegfried,
How about first writing a simple Console app to test your DLL to make sure
that P/Invoke is working properly and can load your DLL. If the Console app
works, then at least you can rule out that problem and you'll know the
problem has something todo with IIS.
Eric
> Thanks Eric,
> I put it in the bin directory that was created by Visual Studio.net when I
[quoted text clipped - 58 lines]
> > >
> > > Siegfried
Siegfried Heintze - 28 Jun 2004 21:41 GMT
Thanks Eric. I've done that and the calls seem to be correct.
> Siegfried,
>
[quoted text clipped - 78 lines]
> > > >
> > > > Siegfried
DotNetJunkies User - 03 Sep 2004 19:46 GMT
Hey i have same problem. Did you find the solution. Pl. mail me at sshilagani@bloomberg.com. Thanks.
---
DotNetJunkies User - 09 Sep 2004 04:06 GMT
Ugghh... I finally figured this out with the help of Microsoft Tech support.
The Administrator need to grant me (the siegfried account) access to the ASP.NET temporary directory (somewhere down in the bowels of the WINNT direcotry). Then I had to use the web.config file to impersonate the siegfied account.
---