473,803 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call C from C# Web Service?

I have the following C# code in my web service:

[DllImport ("CaseAssessmen t.dll",
CallingConventi on=CallingConve ntion.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 9083
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\ASP NET. 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*******@hein tze.com> wrote in message
news:e4******** ******@TK2MSFTN GP11.phx.gbl...
I have the following C# code in my web service:

[DllImport ("CaseAssessmen t.dll",
CallingConventi on=CallingConve ntion.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:Envelop e xmlns:soap="htt p://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>Sy stem.Web.Servic es.Protocols.So apException: Server was
unable to process request. ---&gt; System.DllNotFo undException: Unable to
load DLL (c:\inetpub\hei ntze\AnalyzeRes ults\bin\CaseAs sessment.dll).
at AnalyzeResults. Service1.addr_( Double&amp; X, Double&amp; Y)
at AnalyzeResults. Service1.addr(D ouble&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******** ******@TK2MSFTN GP09.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\ASP NET. 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*******@hein tze.com> wrote in message
news:e4******** ******@TK2MSFTN GP11.phx.gbl...
I have the following C# code in my web service:

[DllImport ("CaseAssessmen t.dll",
CallingConventi on=CallingConve ntion.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*******@hein tze.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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:Envelop e xmlns:soap="htt p://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>Sy stem.Web.Servic es.Protocols.So apException: Server was
unable to process request. ---&gt; System.DllNotFo undException: Unable to
load DLL (c:\inetpub\hei ntze\AnalyzeRes ults\bin\CaseAs sessment.dll).
at AnalyzeResults. Service1.addr_( Double&amp; X, Double&amp; Y)
at AnalyzeResults. Service1.addr(D ouble&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******** ******@TK2MSFTN GP09.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\ASP NET. 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*******@hein tze.com> wrote in message
news:e4******** ******@TK2MSFTN GP11.phx.gbl...
I have the following C# code in my web service:

[DllImport ("CaseAssessmen t.dll",
CallingConventi on=CallingConve ntion.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******** *****@tk2msftng p13.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*******@hein tze.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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:Envelop e xmlns:soap="htt p://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>Sy stem.Web.Servic es.Protocols.So apException: Server was unable to process request. ---&gt; System.DllNotFo undException: Unable to load DLL (c:\inetpub\hei ntze\AnalyzeRes ults\bin\CaseAs sessment.dll).
at AnalyzeResults. Service1.addr_( Double&amp; X, Double&amp; Y)
at AnalyzeResults. Service1.addr(D ouble&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******** ******@TK2MSFTN GP09.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\ASP NET. 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*******@hein tze.com> wrote in message
news:e4******** ******@TK2MSFTN GP11.phx.gbl...
> I have the following C# code in my web service:
>
> [DllImport ("CaseAssessmen t.dll",
> CallingConventi on=CallingConve ntion.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********@bloo mberg.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
3630
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 are very high-performing on their own, make inexpensive database calls and use good caching to avoid excess database hits. However, when service 1 makes a call to service 2, I get several timeout errors per minute (error is "The operation has...
1
1930
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 something wrong with the code that I have below. Thanks.. The following are my two methods where one is calling web service and
3
1948
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 the ATLAS 'enabled' web page but that is all I have found. In the example below, I would like to call the OpenOnline.SaveToPDF.WebServices.Service web service. I get a javascript error when trying to make the web service call saying that...
0
2014
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 Authentication. Within the Web Service we look at the current username and check which user Groups it belongs to.
6
3375
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. When to test it using the web interface on pocket IE, everything is fine. Before there was no such problem, it only happened within a week or so. I suspect it's caused by the server's firewall settings, but how come the first call is ok? This...
3
4682
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 service method call will never return and the entire application will freeze, even though the call is being made on its own background thread, not the main UI thread. Does anyone know any reason why a particular web service method call would cause my...
6
18243
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 = service.getMethod(a, b, c, d) then iterating through for (int i = 0; i < results .Length; i++)
2
5577
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 make it work, i had to break up the webmethod into the BeginXXX, EndXXX model as per http://msdn2.microsoft.com/en-us/library/aa480516.aspx But now, i can no longer call this method from javascript (since to
1
3403
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 used the steps below to make the cross-domain call to the web service. First of all, I created a web service named as HRService.asmx and it is working fine by running under IIS 5.1. Secondy, I make a reference to the web service proxies by writing...
2
5571
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 serialization settings for the build handled the initial slows we encountered when invoking the web service. Since that time, we ported the original VB.net code over to C# - this was done to make it cleaner easier to include the project in the rest of...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.