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 ::InteropServic es;
[DllImport ("DLib.dll")]
extern "C" bool IsValidCheckDig it (String* pDfi);
[DllImport ("DLib.dll")]
extern "C" String* GetComputerName ();
Then in the Service class (TempConvert3Cl ass), added the following
member function declarations:
[System::Web::Se rvices::WebMeth od(
Description="Ch eck a check digit.")]
bool CheckDigit (String* dfi);
[System::Web::Se rvices::WebMeth od(
Description="Ge t Computer Name.")]
String* GetName ();
Finally, in the cpp file, added the member functions:
bool TempConvert3Cla ss::CheckDigit (String* dfi) {
bool bOk = IsValidCheckDig it (dfi);
return bOk;
}
String* TempConvert3Cla ss::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:
[color=blue]
> The page cannot be displayed[/color]
The address of this page is:
There is no specific error or reason for the error shown.
The prototype for the two functions (in DLib.dll) are:
extern DllExport bool IsValidCheckDig it (const char* pDfi);
extern DllExport CString GetComputerName ();
Anyone know what is wrong?
Thanks, Russ
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 ::InteropServic es;
[DllImport ("DLib.dll")]
extern "C" bool IsValidCheckDig it (String* pDfi);
[DllImport ("DLib.dll")]
extern "C" String* GetComputerName ();
Then in the Service class (TempConvert3Cl ass), added the following
member function declarations:
[System::Web::Se rvices::WebMeth od(
Description="Ch eck a check digit.")]
bool CheckDigit (String* dfi);
[System::Web::Se rvices::WebMeth od(
Description="Ge t Computer Name.")]
String* GetName ();
Finally, in the cpp file, added the member functions:
bool TempConvert3Cla ss::CheckDigit (String* dfi) {
bool bOk = IsValidCheckDig it (dfi);
return bOk;
}
String* TempConvert3Cla ss::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:
[color=blue]
> The page cannot be displayed[/color]
The address of this page is:
There is no specific error or reason for the error shown.
The prototype for the two functions (in DLib.dll) are:
extern DllExport bool IsValidCheckDig it (const char* pDfi);
extern DllExport CString GetComputerName ();
Anyone know what is wrong?
Thanks, Russ