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



The information in this article applies to:

  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET (2003)

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: <Inherited Form Name> --- The base class '<base class name>' 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.
  2. Create a Visual C++ Windows Form application (.NET) project in Visual Studio .NET (2003). The Windows Form application must contain the derived form class.
  3. In Solution Explorer, right-click References, and then click Add Reference.
  4. In the Add Reference dialog box, click the .NET tab, and then click Browse.
  5. 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.
  6. Change the base class of the form to the form that is contained in the class library DLL.

    View the form in Design view.

MORE INFORMATION

Steps to Reproduce the Problem

  1. 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.
  2. On the Project menu, click Add Class.
  3. In the Add Class dialog box under the Templates section, click Windows Form (.NET).
  4. In the Name text box, type Form2.
  5. Close the Add Class dialog box.
  6. Right-click Design View on Form2, and then click View Code.
  7. Add the #include "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 <namepsace name>::Form1
  8. Build the project.
  9. 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 "Symptoms" section.

STATUS

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

Modification Type:MajorLast Reviewed:1/6/2006
Keywords:kberrmsg kbprb kbide KB815325 kbAudDeveloper kbAudITPRO