473,405 Members | 2,334 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,405 software developers and data experts.

Using InteropServices in a WebService

I'm trying to use InteropServices in a web service, by following the
examples and info in the article "Consuming Unmanaged DLL Functions"
in the .NET Framework Developer's Guide.

I am able to add prototypes for unmanaged code and compile and link
the C++ managed code web service (based on the TempConvert3
walkthrough). I added web methods to try several calls to unmanaged
DLL's, but none of them work. Here is what I did:

in the web service header file, added the following, right after the
other using statements:

using namespace System::Runtime::InteropServices;
[DllImport ("DLib.dll")]
extern "C" bool IsValidCheckDigit (String* pDfi);
[DllImport ("DLib.dll")]
extern "C" String* GetComputerName ();

Then in the Service class (TempConvert3Class), added the following
member function declarations:

[System::Web::Services::WebMethod(
Description="Check a check digit.")]
bool CheckDigit (String* dfi);

[System::Web::Services::WebMethod(
Description="Get Computer Name.")]
String* GetName ();
Finally, in the cpp file, added the member functions:

bool TempConvert3Class::CheckDigit (String* dfi) {
bool bOk = IsValidCheckDigit (dfi);
return bOk;
}

String* TempConvert3Class::GetName () {
return GetComputerName ();
}
When I run the project, it still works properly when I invoke the
orignial temperature conversion method. The new methods are shown in
the web page, but when I invoke either of them I get a page that says:
The page cannot be displayed


The address of this page is:
http://localhost/TempConvert3/TempConvert3.asmx/GetName

There is no specific error or reason for the error shown.

The prototype for the two functions (in DLib.dll) are:

extern DllExport bool IsValidCheckDigit (const char* pDfi);
extern DllExport CString GetComputerName ();

Anyone know what is wrong?

Thanks, Russ

Jul 21 '05 #1
0 1201

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

Similar topics

0
by: Richard Ruben | last post by:
We have a very strange problem when we are using the OpenFileDialog component. Consider the following code: --------------- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As...
1
by: Wm. Scott Miller | last post by:
I have a Custom DTS Task for SQL Server and I've got it working fine, except for when I try to access its properties from an ActiveX script. I have added a new property called Length and a method...
7
by: www.dir | last post by:
Hi, I am interested whether there is a significant differense if I put on top of my class using CustomNameSpace or If I call methods in my code by CustomNameSpace.MyMethod() I am interested...
9
by: Ron | last post by:
Hello, Is it required to use Imports System.Runtime.InteropServices to run C++ API code? I ask because I thought I read somewhere that this was required. If it is not required would it...
0
by: Russ | last post by:
I'm trying to use InteropServices in a web service, by following the examples and info in the article "Consuming Unmanaged DLL Functions" in the .NET Framework Developer's Guide. I am able to...
2
by: Robert Bravery | last post by:
Hi all, Being new to C# and .net I often don't know how to use things. I have created an app that imports excel data, it works well, with methods to open excel, extract the data and close excel....
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
7
by: =?Utf-8?B?VGVycnkgSG9sbGFuZA==?= | last post by:
I have a vb.net app that opens an excel worksheet, reads data and then closes the sheet. Im noticing that the Excel process is still running after I have closed and disposed of my excel objects. ...
4
by: Oriane | last post by:
Hi there, I need to use an ActiveX inside a Web service. My problem is that I need an handle on this Com component, so I add a reference to my .Net project, and I create an instance of class of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.