Microsoft KB Archive/894438

= You receive an &quot;Object reference not set to an instance of an object&quot; error message when you try to open a project that contains an inherited user control in Visual Studio .NET or Visual Studio 2005 =

Article ID: 894438

Article Last Modified on 12/11/2006

-

APPLIES TO


 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual C# 2005 Express Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ 2005 Express Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Basic 2005

-





SYMPTOMS
When you try to open a project that contains an inherited user control, you receive an error message that is similar to the following:

Object reference not set to an instance of an object.

This problem occurs in Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005.

Note This problem occurs when your project contains Web references.



CAUSE
This problem occurs when you save your project with XML attribute characters that are not valid in the project path. Examples of XML attribute characters that are not valid follow:

When you try to open the project that contains the inherited user control, Visual Studio .NET 2003 or Visual Studio 2005 scans through the references to find the base type of the control. All references are stored in an XML fragment. The &quot;#&quot; character and the &quot;&&quot; character are valid Windows directory characters. However, they are not valid characters XML attribute characters. This causes Visual Studio .NET 2003 or Visual Studio 2005 to stop scanning through the references when these characters are encountered. Therefore, the base type of the control is not found.



WORKAROUND
To work around this problem, you must avoid using XML attribute characters that are not valid. Do not use the &quot;#&quot; character and the &quot;&&quot; character in the project path.



Steps to reproduce the problem

 * 1) Start Visual Studio .NET 2003 or Visual Studio 2005.
 * 2) On the File menu, click New, click Project, click Visual Basic Projects, and then click Windows Application.

Note In Visual Studio 2005, click Visual Basic.
 * 1) Type the following in the Location box, and then click OK.


 * 1) In Solution Explorer, right-click Windows Application1, click Add, click Add User Control, click User Control under Templates, and then click Open.
 * 2) On the View menu, click ToolBox.
 * 3) Add the TextBox control to the user control in the Designer.
 * 4) On the Build menu, click Build Solution.
 * 5) In Solution Explorer, right-click Windows Application1, click Add, click Add Inherited Control, click Inherited User Control under Templates, and then click Open.
 * 6) In the Inheritance Picker window, click UserControl1 that you created in step 4, and then click OK.
 * 7) In Solution Explorer, right-click Windows Application1, and then click Add Web Reference.
 * 8) In the Add Web Reference dialog box, type your  in the URL box, and then click Add Reference.
 * 9) On the File menu, click Close to close all documents.
 * 10) Try to open UserControl2.vb in the Designer.

You receive the error message that is mentioned in the &quot;Symptoms&quot; section.

Keywords: kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbtshoot kbbug KB894438

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.