You receive a "NullReferenceException" error message or an "OutOfMemoryException" error message when you run the MultiThreaded TCP/IP Listener sample application in Visual Studio .NET (837222)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

In Microsoft Visual Studio .NET, when you run the application that is associated with the "Windows Forms: Multi-Threaded TCP/IP Listener sample" Help topic, the Microsoft Windows Form that is named Client may close unexpectedly and you may receive one or more of the following error messages:

Message 1

An unhandled exception of type 'System.NullReferenceException' occurred in Client.exe
Additional information: Object reference not set to an instance of an object.
Message 2

An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll
Additional information: Too many items in list box.
Note If you are using Visual Studio .NET 2003, and you follow the instructions that appear in the "To run this sample" section of the "Windows Forms: Multi-Threaded TCP/IP Listener Sample" Help topic, this behavior does not occur because the Visual Studio .NET 2003 Help topic contains the correct instructions to run the sample.

CAUSE

The application that is associated with the "Windows Forms: Multi-Threaded TCP/IP Listener sample" Help topic is a solution that contains multiple projects.

In Microsoft Visual Studio .NET 2003, this problem occurs because the startup configuration for the projects is incorrectly set to Start instead of to Start without debugging.

In Microsoft Visual Studio .NET 2002, this problem occurs because the startup configuration for the solution is incorrectly set to Single Startup Project instead of to Multiple Startup Projects.

WORKAROUND

To work around this problem, change the configuration settings for your solution or for your projects. To do this, follow these steps:
  1. In Visual Studio .NET, open the TCPIPListener solution.
  2. In Solution Explorer, right-click the solution, and then click Properties. The Solution 'TCPIPListener' Property Pages dialog box appears.
  3. Click the Multiple Startup Projects option.
  4. Under Project, click Client.
  5. In the Action field of the Client project, click Start without debugging.
  6. Under Project, click Listener.
  7. In the Action field of the Listener project, click Start without debugging.
  8. Click OK.
  9. On the Debug menu, click Start Without Debugging.

MORE INFORMATION

Steps to reproduce the behavior

Visual Studio .NET 2003

To reproduce the behavior that appears in the "Symptoms" section, follow these steps:
  1. In Visual Studio .NET 2003, open the TCPIPListener solution. This solution is located in the Installation Path\Vb7\VB Samples\WinForms-Threads-TCPListener\TCPIPListener folder.

    Note Installation Path is a placeholder for the absolute path of the folder where Visual Studio .NET is installed.
  2. On the Debug menu, click Start. The Client Windows Form and the Listener Windows Form appear.
  3. Close the Listener Windows Form.

    The behavior that appears in the "Symptoms" section of this article may occur.

Visual Studio .NET 2002

To reproduce the behavior that appears in the "Symptoms" section, follow these steps:
  1. In Visual Studio .NET 2002, open the TCPIPListener solution. This solution is located in the Installation Path\Vb7\VB Samples\WinForms-Threads-TCPListener\TCPIPListener folder.

    Note Installation Path is a placeholder for the absolute path of the folder where Visual Studio .NET is installed.
  2. On the Debug menu, click Start. The Client Windows Form appears.
  3. Click Start, and then click Stop. Do this more than one time.

    The behavior that appears in the "Symptoms" section of this article may occur.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web sites:

Modification Type:MinorLast Reviewed:3/4/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kberrmsg kbProductSample kbDownload kbprb KB837222 kbAudDeveloper