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