Microsoft KB Archive/253863

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Article ID: 253863

Article Last Modified on 3/4/2004



APPLIES TO

  • Microsoft Exchange Development Kit 5.5
  • Microsoft Exchange Server 2003 Software Development Kit



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.

RESOLUTION

NOTE: 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));
                

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Install the Sample Gateway.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

    200669 HOWTO: Install the Sample Gateway in Exchange Development Kit

  2. In Microsoft Visual C++, from the Tools menu, click Options, and then click Directories. Make sure that the Platform SDK Include files are listed before the Visual C++ Include files in the list.
  3. Open the ExchSDK.dsw project and rebuild the debug version of the Exchange Development Kit (EDK) library, ExchSDKd.lib.
  4. From the Project menu, click Setting, click Link, click General, and then click to clear the Incremental Link option.
  5. Rebuild the Gwsample.exe file.
  6. Set a breakpoint on line 389 in the Gwmain.c file.
  7. Run the sample as a console application under the debugger. If the service is registered under HKLM\SYSTEM\CurrentControlSet\Services\SGW, pass "notserv SGW" as parameters.


REFERENCES

For 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:

Keywords: kbbug kbmsg kbpending KB253863