BUG: 16-bit RPC Samples Print Meaningless Error Codes (139717)



The information in this article applies to:

  • Microsoft Win32 Software Development Kit (SDK) 3.1
  • Microsoft Win32 Software Development Kit (SDK) 3.5
  • Microsoft Win32 Software Development Kit (SDK) 3.51
  • Microsoft Win32 Software Development Kit (SDK) 4.0

This article was previously published under Q139717

SYMPTOMS

Some of the 16-bit RPC samples print meaningless error codes. For example:
Runtime reported exception 378535963

CAUSE

The 16-bit applications method for generating exceptions are different from those used by 32-bit applications. This is encapsulated to ease programming. Please look in the header file Rpcx86.h.

RpcExceptionCode is defined as _exception_code. However, _excpetion_code is a 16-bit integer, so when this is printed as an unsigned long integer, the result is not meaningful.

RESOLUTION

Any of the following methods should result in meaningful error codes:
  • Explicitly cast the value returned by RpcExceptionCode() as an unsigned long. For example:

          printf("Runtime reported exception %ld\n", (unsigned long)
             RpcExceptionCode());
    						
    -or-
  • Use an unsigned long variable to trap the value of RpcExceptionCode(). For example:
          unsigned long ulCode;
          ulCode = RpcExceptionCode();
          printf("Runtime reported exception %ld\n",  ulCode );
    						
    Note that this method is used by the samples that do not exhibit the problem.

    -or-
  • Print the value as an unsigned quantity. For example:
          printf("Runtime reported exception %u\n", RpcExceptionCode());
    						
    -or-
          printf("Runtime reported exception %ul\n", RpcExceptionCode());
    						

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are reasearching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This bug is exhibited by the following samples:

callback\callc.c
data\dunion\dunionc.c
data\inout\inoutc.c
data\repas\repasc.c
data\xmit\xmitc.c
doctor\doctorc.c
rpcssm\rpcssmc.c

REFERENCES

The SDK header file Rpcerr.h that installs with the 16-bit runtimes for RPC.

Modification Type:MajorLast Reviewed:10/16/2002
Keywords:kbAPI kbBug kbnetwork kbRPC KB139717