Microsoft KB Archive/815325

= The Visual Studio .NET IDE designer fails when implementing an inherited form programmatically in Managed Visual C++ .NET or Visual C++ 2005 =

Article ID: 815325

Article Last Modified on 1/6/2006

-

APPLIES TO


 * Microsoft Visual C++ 2005 Express Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition

-





SYMPTOMS
When you try to inherit a form from another form programmatically in the same Managed Visual C++ Windows Form application, the program builds correctly. However, when you try to view the inherited form in Design view in the Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 IDE Designer, you may receive the following error message:

The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:  --- The base class ' ' could not be loaded. Ensure the assembly has been referenced or built if it is part of the project.

You may also receive the error message in the Task List window.



WORKAROUND
To work around this problem, create a separate Managed Class Library that contains the base form class that must be inherited. Build the class library, and then reference the base form class from the application that contains the inherited form. To do this, follow these steps:
 * 1) Create a Microsoft Visual C++ Class Library (.NET) project in Visual Studio .NET (2003).

The project must contain the base form class.

Note In Microsoft Visual Studio 2005, create a Microsoft Visual C++ Class Library project.
 * 1) Create a Visual C++ Windows Form application (.NET) project in Visual Studio .NET (2003). The Windows Form application must contain the derived form class.
 * 2) In Solution Explorer, right-click References, and then click Add Reference.
 * 3) In the Add Reference dialog box, click the .NET tab, and then click Browse.
 * 4) In the Select Component dialog box, select the class library dynamic-link library (DLL) that was generated in step 1. Click OK to close the Add Reference dialog box.
 * 5) Change the base class of the form to the form that is contained in the class library DLL.

View the form in Design view.



Steps to Reproduce the Problem
 Create a Visual C++ Windows Form application (.NET) project in Visual Studio .NET (2003).

Note In Visual Studio 2005, create a Microsoft Visual C++ Class Library project. On the Project menu, click Add Class. In the Add Class dialog box under the Templates section, click Windows Form (.NET). In the Name text box, type Form2 . Close the Add Class dialog box. Right-click Design View on Form2, and then click View Code.</li>  Add the #include &quot;Form1.h directive at the beginning of the file. Change the base class for Form2 from System::Windows::Forms::Form to public __gc class Form2 : public ::Form1 </li> Build the project.</li> Click the Form2.h[Design] tab in the Form Designer editor to view Form2 in design mode. You may receive the error message in the &quot;Symptoms&quot; section.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Additional query words: inherited designer base form

Keywords: kberrmsg kbide kbprb KB815325

-

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

© Microsoft Corporation. All rights reserved.