Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE

时间:2023-03-08 21:27:44

原文地址:https://support.microsoft.com/en-us/kb/963017

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.
Action
You attempt to use a -bit component within the Microsoft Visual Studio Integrated Development Environment (IDE).
Result . When adding control contained within an external -bit assembly to to the Visual Studio Toolbox, you receive the following error message. "<Control Name.dll> is not a valid .NET module". . When dragging and dropping a UserControl defined in a -bit assembly to a Form in another project within the same solution, you receive the error: "Failed to load toolbox item <UserControl Name>. It will be removed from the toolbox." . When opening the Visual Studio Windows Form Designer for a form that attempts to instantiate a control in a -bit assembly, you receive the following errors in the Windows Form designer. "Could not find type <typename>. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built." "The variable <variable name> is either undeclared or was never assigned. " Call Stack: at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
Cause
This behavior is by design. Visual Studio is a -bit process, and therefore can only execute -bit modules. While Visual Studio allows you to add a reference to a -bit assembly, it cannot actually JIT compile it to -bit and execute it in process.
Resolution . Rebuild the assembly using the "AnyCPU" setting. This would allow the component to run within a -bit process (such as Visual Studio), or in a -bit process. Advanced Compiler Settings Dialog Box (Visual Basic)
http://msdn.microsoft.com/en-us/library/07bysfz2.aspx /platform (Specify Output Platform) (C# Compiler Options)
http://msdn.microsoft.com/en-us/library/zekwfyz4.aspx If you are using a third party component and cannot rebuild it yourself, contact the component vendor to see if an "AnyCPU" version of the assembly is possible to obtain. This will allow the component to Just-In-Time (JIT) compile to run as either a -bit or -bit module, depending on the machine architecture the operating system and host process are targeting. . Add the assembly as a reference and load the control dynamically at run-time. Although you still would be unable to use the control within any designer inside Visual Studio, you can still write the code needed to instantiate the control and set it's properties accordingly.
More Information Is there a -bit version of Visual Studio or Visual Studio ?
http://support.microsoft.com/default.aspx/kb/951801 Process Interoperability http://msdn.microsoft.com/en-us/library/aa384231(VS.85).aspx 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: - Last Review: // :: - Revision: 1.1
Applies to Microsoft Visual Studio Express Edition
Microsoft Visual Studio Professional Edition
Microsoft Visual Studio Service Pack
Microsoft Visual Studio Standard Edition
Microsoft Visual Studio Team Edition for Software Developers
Microsoft Visual Studio Team Suite
Microsoft Visual Studio Academic Edition
Microsoft Visual Studio Professional Edition
Microsoft Visual Studio Service Pack
Microsoft Visual Studio Standard Edition
Microsoft Visual Studio Team System Development Edition
Microsoft Visual Studio Team System Team Suite Keywords: kbnomt kbrapidpub KB963017