Saturday, October 30, 2010

Error message: Msvc32i MFC application has encountered a problem and needs to close MFC vc++ c++

Sometimes starting windows xp machine will get the following error message

msvc32i MFC Application has encountered a problem and needs to close.

This problem may occur if the ClientMan program is installed on your computer.

To resolve this issue, remove the ClientMan program from your computer by downloading and applying the removal tool. To do so, follow these steps:


1 Click Start, point to All Programs, and then click Internet Explorer.

2 Type the following Web address (URL) in the Internet Explorer Address bar:

3 In the File Download dialog box, click Save.

4 In the Save As dialog box, specify where you want to download the file, and then click Save.

5 Close all instances of Internet Explorer, and then close all Windows Explorer windows.

6 Double-click the downloaded Remcli.zip file.

7 In the WinZip dialog box, double-click the Remcli.exe file.
Restart your computer.

8 Locate the %SYSTEMROOT%\Program Files on your computer, and then delete the ClientMan folder from your computer.

Note %SYSTEMROOT% is a Windows environment variable that identifies the folder where Windows XP is installed (for example, C:\Windows). To view the value that is associated with %SYSTEMROOT% on your computer, and to view other environment variables on your computer, type set at a command prompt, and then press ENTER.

Friday, October 29, 2010

Error LNK2001: unresolved external symbol vc++ c++ error message

When compiling an MFC application using the single-threaded run-time library, you receive the following two unresolved external error messages:

nafxcwd.lib(thrdcore.obj) : error LNK2001:
unresolved external symbol "__beginthreadex"


nafxcwd.lib(thrdcore.obj) : error LNK2001:
unresolved external symbol "__endthreadex"

Starting with version 3.0, all MFC classes are "thread safe" and require the multi-threaded run-time libraries to link successfully. Many people try to use the single-threaded run-time libraries because they assume these libraries are needed to enable the application to run in Win32s. This is not the case. MFC versions 3.0 and later will use a single thread, so as long as you are not creating additional threads in the application, the application will run under Win32s.

To avoid these unresolved external errors, do not set the Project Settings to Single-Threaded for an MFC version 3.0 or later application. This setting can be changed by doing the following:

On Microsoft Visual C++ .NET 2003

1. Click the Project menu.
2. Click Properties.
3. Expand Configuration Properties, and then click C/C++.
4. Click Code Generation.
5. In the right pane, make a selection other than Single-threaded or Single-threaded Debug in the Runtime Library list.

On Microsoft Visual C ++ 2.x, 5.0, and 6.0

1. Select the Project menu.
2. Select the Settings... option.
3. Select the C/C++ tab.
4. Select Code Generation on the Category list box.
5. Finally, make a selection other than Single-Threaded on the Use Run Time Library list box.

On Microsoft Visual C++ 4.x

1. Select the Build menu.
2. Select the Settings... option.
3. Select the C/C++ tab.
4. Select Code Generation on the Category list box.
5. Finally, make a selection other than Single-Threaded on the Use Run Time Library list box.

Debug Assertion failed - Error message when upgrading Visual C++ to Visual C++ 4.2 or a later version mfc , vc++ , c++

When upgrading vc++ to Visual c++ 4.2 or later you may receive the following error message

Debug Assertion failed
Program: my.exe
File: dbgheap.c
Line: 1017
Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)


The reason for this error message is

The CWinApp destructor in MFC included with Visual C++ 4.2 and later now frees the data assigned to the member variables shown above by passing the pointer to the free() function. Doing this prevents memory leaks, which would occur if an MFC regular DLL were dynamically loaded and unloaded.

To solve this issue

If you assign a value to m_pszAppName, m_pszRegistryKey, m_pszExeName, m_pszHelpFilePath, or m_pszProfileName, the data must be dynamically allocated on the heap. You may want to use the _tcsdup() run-time library function to do this.

Also, free the memory associated with the current pointer before assigning a new value. Here is an example:

// First free the string that was allocated by MFC in the startup
// of CWinApp. The string is allocated before InitInstance is
// called.
free((void*)m_pszProfileName);

// Change the name of the .INI file--CWinApp destructor will free
// the memory.
m_pszProfileName=_tcsdup(_T("d:\\somedir\\myini.ini"));