Cannot Display Inherited Form in Form Designer When Base Form Defined in 64-bit Assembly

Article translations Article translations
Close Close
Article ID: 967050 - View products that this article applies to.
Expand all | Collapse all
Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Symptom

Symptom 1
------------------
When attempting to add an inherited form using Visual Inheritance in a Visual Basic or C# project, you receive the following error:

"Warning: No built assemblies contain components to inherit from. Build the current application, or click Browse and select a previously built assembly from another application."


Symptom 2
------------------ 
When attempting to open an inherited form in the Windows Form Designer, the following error is displayed.

"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: <filename>  <class name> --- The base class '<base class name>' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. "

Cause

The Form Designer requires a compiled assembly in order to display an inherited form. If the base form class is contained within an assembly that was compiled using the x64 or Itanium options, they cannot be opened by the Form Designer. This is because Visual Studio is a 32-bit process, and cannot execute code in a 64-bit (x64 or Itanium) module.

Resolution

Make sure the base form(s) are defined in an assembly that is compiled using the "AnyCPU" build option. This allows form classes defined within the assembly to be used in either a 32-bit process (such as Visual Studio), or in a 64-bit custom process.

More Information

Steps to Reproduce Problem
=======================
1. Create a new Windows Forms project. By default, Form1 is created.
2. On the Project menu, click <project name> Properties to view the project's properties.
3. If you are using Visual Basic, click the Compile tab, then click Advanced Compile Options. Set the Target CPU to "x64", and click OK. If you are using Visual C#, click the Build tab, and set the Platform Target to "x64".
4. On the Build menu, click Build Solution. This will build an assembly targeting the x64 platform.

Steps to Reproduce Symptom 1
---------------------------------------------
5. On the Project menu, click Add New Item.
6. Select Windows Forms, select Inherited Form, and then click Add.

Note that you receive the error "Warning: No built assemblies contain components to inherit from. Build the current application, or click Browse and select a previously built assembly from another application." This occurs even if you browse for and manually select the class library assembly you compiled previously.

Steps to Reproduce Symptom 2
-----------------------------------------------
7. On the Project menu, click Add Class. Select the default name (class1), and click Add.
8. If you are using Visual Basic, use this code in the class file.

Imports System.Windows.Forms
Public Class Class1
   Inherits Form1
End Class

9. If you are using Visual C#, use this code in the class file.

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    class Class1:Form1
    {
    }
}

10. On the Build menu, click Build Solution. The project should compile.
11. Attempt to open the Class1 inherited form in the Windows Form Designer.

Note that you receive the error: "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: Class1 --- The base class 'WindowsApplication1.Form1' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.

 

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

Properties

Article ID: 967050 - Last Review: January 26, 2009 - Revision: 1.1
APPLIES TO
  • Microsoft Visual Studio 2005 Team Suite
  • Microsoft Visual Studio Team System 2008 Team Suite
Keywords: 
kbnomt kbrapidpub KB967050

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com