473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to call C from C# Web Service?

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
Nov 21 '05 #1
6 9068
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
"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
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

Nov 21 '05 #2
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.SoapExc eption: Server was
unable to process request. ---&gt; System.DllNotFoundException: Unable to
load DLL (c:\inetpub\heintze\AnalyzeResults\bin\CaseAssessm ent.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>


"Eric Cherng" <ericch1@remove_the_dot-hotmai.l.com> wrote in message
news:#t**************@TK2MSFTNGP09.phx.gbl...
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
"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
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


Nov 21 '05 #3
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
"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.SoapExc eption: Server was
unable to process request. ---&gt; System.DllNotFoundException: Unable to
load DLL (c:\inetpub\heintze\AnalyzeResults\bin\CaseAssessm ent.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>


"Eric Cherng" <ericch1@remove_the_dot-hotmai.l.com> wrote in message
news:#t**************@TK2MSFTNGP09.phx.gbl...
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
"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
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



Nov 21 '05 #4
Thanks Eric. I've done that and the calls seem to be correct.

"Eric Cherng" <ericch1@remove_the_dot-hotmai.l.com> wrote in message
news:#e*************@tk2msftngp13.phx.gbl...
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
"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.SoapExc eption: Server was unable to process request. ---&gt; System.DllNotFoundException: Unable to load DLL (c:\inetpub\heintze\AnalyzeResults\bin\CaseAssessm ent.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>


"Eric Cherng" <ericch1@remove_the_dot-hotmai.l.com> wrote in message
news:#t**************@TK2MSFTNGP09.phx.gbl...
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
"Siegfried Heintze" <si*******@heintze.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
> 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
>
>



Nov 21 '05 #5
Hey i have same problem. Did you find the solution. Pl. mail me at ss********@bloomberg.com. Thanks.

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 21 '05 #6
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.

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Barb | last post by:
Hello, I have a (C#) web service being consumed by a high volume "asp classic" site. It worked perfectly until I tried consuming a second web service from the first web service. Both services...
1
by: kkao77 | last post by:
Someone help me please. I've tried to write an asynchronous method, but it didn't call my web service, do I need to do something in my webservice project to make it work? or if there is...
3
by: Marshall | last post by:
Hello, I am wondering if it is possible to call a remote web service using ATLAS and if so, how. I have read several docs which show how to call a web service that is within the same project as...
0
by: Griff | last post by:
Overview When the first call to our Web Service causes an exception, the Web Service caches that user's credentials for its life time. Details We have a Web Service which uses Windows...
6
by: alho | last post by:
The web service is called by a program running on pocket pc. When to call the web service, the first call is still ok, but for the second or later calls, it will throw "403 Forbidden" WebException....
3
by: =?Utf-8?B?Y2hlbmRyaWNrcw==?= | last post by:
I have a C# winforms application that makes periodic web service calls in background thread to my web service server. These calls work fine almost all the time but on rare occassions the web...
6
by: plork | last post by:
hi all i'm calling a web service method and can get it's results just fine however i want to grab the repsonse message from the call is anyone able to tell me how i do this? results =...
2
by: jojoba | last post by:
Hello to all! I have a fairly simple webservice running in asp.net ajax under c# (vs 2008). I built the service and it runs just dandy when i test it by itself in visual studio. However, to...
1
by: y2ktan | last post by:
hi guys, I am building my web page using AJAX in ASP.Net, now I want to make a cross-domain call from my web application to my web service that both of them are hosted at different machine. I...
2
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.