FIX: SNMP Sample Generates an Application Error

ID: Q124961

The information in this article applies to:

SYMPTOMS

The Win32 SDK for Windows NT 3.5 contains a SNMP sample called SNMPUTIL (\MSTOOLS\SAMPLES\WIN32\SNMP\SNMPUTIL). Building this sample generates an executable file that causes an access violation. The message box displayed resembles the following:

                     snmputil.exe - Application Error
   -----------------------------------------------------------------
   The instruction at <address> referenced memory at <address>.  The
   memory could not be "read".

CAUSE

One part of the SNMP run times uses the C run-time routines provided by CRTDLL.DLL. The other part of the SNMP run times uses the C run-time routines that the application uses. Because many people are using Visual C++ to build the samples, the run time routines used are in MSVCRT20.DLL. The access violation occurs when memory allocated using one run time version are freed using a different copy of the run time library.

RESOLUTION

One possible solution is to build the sample application using the CRTDLL.DLL version of the run time library. If you are using the makefile supplied with the Win32 SDK, one way to accomplish this is to:

1. Copy NTWIN32.MAK from your include directory to the working directory

   for the sample.
2. Change all references to MSVCRT.LIB in NTWIN32.MAK to CRTDLL.LIB.

If you are using a Visual C++ make file, you can:

1. Select the "Ignore All Default Libraries" check box in the Linker

   Project Settings property page.
2. Add CRTDLL.LIB to the "Object/Library Modules" section in the Linker
   Project Settings property page.

NOTE: CRTDLL.LIB does not ship with Visual C++. You can get the CRTDLL.LIB file from the Win32 SDK in the \MSTOOLS\LIB\CRT\<PLATFORM> directory, where <PLATFORM> would be replaced with the type of machine you are using (I386, alpha, and so forth).

If you are using MFC 3.0, you will not be able to use CRTDLL.DLL because MFC 3.0 uses some functions that are not supplied in CRTDLL.DLL.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in the Win32 SDK version 3.51.

Additional query words:

Keywords          : kbnetwork kbAPI kbNTOS350bug kbNTOS351fix kbSDKPlatform kbSNMP kbGrpNet 
Issue type        : kbbug
Solution Type     : kbfix

Last Reviewed: July 31, 1998