473,382 Members | 1,355 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,382 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 1197

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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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...

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.