Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 894438 - Last Review: December 11, 2006 - Revision: 3.8
You receive an "Object reference not set to an instance of an object" error message when you try to open a project that contains an inherited user control in Visual Studio .NET or Visual Studio 2005
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.
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 "#"
character and the "&" 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.
To work around this problem, you must avoid using XML
attribute characters that are not valid. Do not use the "#" character and the
"&" character in the project path.
Steps to reproduce the problem
- Start Visual Studio .NET 2003 or Visual Studio 2005.
- 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. - Type the following in the Location box,
and then click OK.
Drive_Letter:\My&Directory - In Solution Explorer, right-click Windows
Application1, click Add, click Add User
Control, click User Control under
Templates, and then click Open.
- On the View menu, click
ToolBox.
- Add the TextBox control to the user
control in the Designer.
- On the Build menu, click Build
Solution.
- In Solution Explorer, right-click Windows
Application1, click Add, click Add Inherited
Control, click Inherited User Control under
Templates, and then click Open.
- In the Inheritance Picker window, click
UserControl1 that you created in step 4, and then click
OK.
- In Solution Explorer, right-click Windows
Application1, and then click Add Web
Reference.
- In the Add Web Reference dialog box, type
your WebService in the
URL box, and then click Add
Reference.
- On the File menu, click
Close to close all documents.
- Try to open UserControl2.vb in the Designer.
You
receive the error message that is mentioned in the "Symptoms" section.
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
| kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbtshoot kbbug KB894438 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate