Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2004

Tip: Looking for answers? Try searching our database.

How to call C from C# Web Service?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Siegfried Heintze - 25 Jun 2004 00:53 GMT
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. ---&gt; System.DllNotFoundException: Unable to
load DLL (c:\inetpub\heintze\AnalyzeResults\bin\CaseAssessment.dll).
  at AnalyzeResults.Service1.addr_(Double&amp; X, Double&amp; Y)
  at AnalyzeResults.Service1.addr(Double&amp; X, Double&amp; 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.

---

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.