BUG: Sample Gateway (SGW) Returns Exception When it Is Run as a Console Application (253863)
The information in this article applies to:
- Microsoft Exchange Development Kit (EDK) 5.0
- Microsoft Exchange Development Kit (EDK) 5.5
This article was previously published under Q253863 SYMPTOMS
When you debug the Sample Gateway (SGW) as a console application, an unhandled exception may occur.
CAUSE
The definition of the HRESULT_FROM_WIN32 macro in the Winerror.h file is as follows:
#define HRESULT_FROM_WIN32(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))
In this macro, x is evaluated twice. In our situation here, x is the RegCloseKey function. The first time that the RegCloseKey function is called, the registry key handle is closed. The second time that the RegCloseKey function is called, the handle is invalid, which causes an "Invalid handle" exception to be returned.
RESOLUTIONNOTE: The SGW will function correctly and ignore the exception, if you click OK, click Go on the toolbar, click Yes, and then click Go again.
To resolve this problem, modify line 389 in the Gwmain.c file. Replace the following line
HR_LOG(HRESULT_FROM_WIN32(RegCloseKey(hkParameters)));
with these two lines:
DWORD err=RegCloseKey(hkParameters);
HR_LOG(HRESULT_FROM_WIN32(err));
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. REFERENCESFor additional information on installing the sample gateway, click the article number below
to view the article in the Microsoft Knowledge Base:
200669 HOWTO: Install the Sample Gateway in Exchange Development Kit
For information on running the sample gateway as a console application, see the following article in the Microsoft Knowledge Base: 199087 HOWTO: Debug the Sample Gateway as a Console Application
For a complete description of building, installing, and configuring the sample gateway, see the MSDN article "Using the Sample Gateway" at the following Web site:
Modification Type: | Minor | Last Reviewed: | 3/4/2004 |
---|
Keywords: | kbBug kbMsg kbpending KB253863 |
---|
|