Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.
When you run a Unicode-enabled application that uses the FreeAddrInfo Windows Sockets function, or that uses helper classes such as ATL::CSocketAddr on a computer that is running Microsoft Windows Server 2003 or Microsoft Windows XP, you may receive the following error message:
The procedure entry point FreeAddrInfoW could not be located in the dynamic link library WS2_32.dll.
The ws2_32.dll library does not export the FreeAddrInfoW symbol that you must have to use the Unicode version of the FreeAddrInfo function.
To resolve this problem, follow these steps:
- Copy the Atlsocket.h file to any directory that you want to use. This file is located in the following directory: Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include
- Add the following block of code to the copy of the Atlsocket.h file that you created in step 1.
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "mswsock.lib")
//Start of Addition
#if _WIN32_WINNT < 0x0502
#define ADDRINFOT addrinfo
#define GetAddrInfo getaddrinfo
#define FreeAddrInfo freeaddrinfo
//End of Addition namespace ATL
- Start Microsoft Visual C++.
- On the Tools menu, click Options. In the left pane of the Options dialog box, expand Projects, and then click VC++ Directories.
Note If you are using Visual C++ Express Edition, expand Projects and Solutions in the left pane of the Options dialog box, and then click VC++ Directories.
- Under Show directories for, click Include files. Then, add the directory where the modified version of the Atlsocket.h file is located to the top of the list.
- Rebuild you application
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Steps to reproduce the problem
- Start Microsoft Visual Studio .NET 2003.
- On the File menu, point to
New, and then click Project.
Visual C++ Projects under Project Types. Then, click Win32 Console Project under
- In the Name box, type
Sample, and then click OK.
- In the Win32 Application Wizard dialog box, click to select the ATL and the Add Support for check boxes under Application Settings, and then click Finish.
- In the Sample.cpp file, replace the existing default code with the following code.
- In Solution Explorer, right-click the project node, and then click Properties.
- In the project Property Pages dialog box, click General under Configuration Propertiesin the left pane. In the right pane, set the Character Set property to Use Unicode Character Set. Click
- On the Build menu, click Build Solution to build the application. You may notice that no compilation errors or linking errors occur during the build process.
- On the Debug menu, click Start Without Debugging. You may notice that you receive the error message that is described in the "Symptoms" section.
Note The CAsyncSocket class is an MFC class. The CSMTPConnection class is an ATL class.
The problem that is described in the "Symptoms" section occurs in any Unicode-enabled application that uses the FreeAddrInfo Windows Socket function on a computer that is running Windows Server 2003 or Windows XP. Because the ATL CSocketAddr class uses the FreeAddrInfo function, the same problem also occurs in ATL 7.1. Any class in ATL 7.1 and MFC 7.1 that uses the CSocketAddr class to enable IPv6 support reflects this behavior. For example, the CAsyncSocket class and the CSMTPConnection class use the CSocketAddr class.
ATL server classes such as CAtlHttpClient and CSoapSocketClientT use the ZEvtSyncSocket class, and display the same error. This behavior occurs because the ZEvtSyncSocket internal class uses the CSocketAddr class in its implementation.
Note The CAtlHttpClient class provides HTTP client support. The CSoapSocketClientT class provides XML Web services client support.
For more information about changes that have been made to ATL, visit the following Microsoft Developer Network (MSDN) Web site: