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

原文地址: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 64-bit component within the Microsoft Visual Studio Integrated Development Environment (IDE).
Result

1. When adding control contained within an external 64-bit assembly to to the Visual Studio Toolbox, you receive the following error message.

"<Control Name.dll> is not a valid .NET module".

2. When dragging and dropping a UserControl defined in a 64-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."

3. When opening the Visual Studio Windows Form Designer for a form that attempts to instantiate a control in a 64-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 32-bit process, and therefore can only execute 32-bit modules. While Visual Studio allows you to add a reference to a 64-bit assembly, it cannot actually JIT compile it to 64-bit and execute it in process.
Resolution

1. Rebuild the assembly using the "AnyCPU" setting. This would allow the component to run within a 32-bit process (such as Visual Studio), or in a 64-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 32-bit or 64-bit module, depending on the machine architecture the operating system and host process are targeting.

2. 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 64-bit version of Visual Studio 2005 or Visual Studio 2008?
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: 963017 - Last Review: 01/19/2009 20:39:01 - Revision: 1.1
Applies to

    Microsoft Visual Studio 2005 Express Edition
    Microsoft Visual Studio 2005 Professional Edition
    Microsoft Visual Studio 2005 Service Pack 1
    Microsoft Visual Studio 2005 Standard Edition
    Microsoft Visual Studio 2005 Team Edition for Software Developers
    Microsoft Visual Studio 2005 Team Suite
    Microsoft Visual Studio 2008 Academic Edition
    Microsoft Visual Studio 2008 Professional Edition
    Microsoft Visual Studio 2008 Service Pack 1
    Microsoft Visual Studio 2008 Standard Edition
    Microsoft Visual Studio Team System 2008 Development Edition
    Microsoft Visual Studio Team System 2008 Team Suite

Keywords:

    kbnomt kbrapidpub KB963017 
时间: 2024-10-04 01:13:03

Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE的相关文章

Win7 64 安装Visual Studio 2010和SQL Server 2008 R2

1. 在MSDN,我告诉你下载安装文件,VS 2010 不论32位还是64位都是同一个文件,cn_visual_studio_2010_ultimate_x86_dvd_532347.iso.SQL下载企业版的cn_sql_server_2008_r2_enterprise_x86_x64_ia64_dvd_522233.iso.之所以用VS 2010 搭配SQL 2008,是因为我在装完了VS 2010后,发现附带安装了SQL 2008的一些配置管理工具.(而且学校机房装的是VS 2008 +

解决安装Visual Studio 2012 vs2012 后,L2TP VPN连接789错误的问题(Win7 64位旗舰版)

现象,安装完VS2012后,L2TP 的VPN出现789错误,百思不得其解,后来看到微软的网站上,一个俄罗斯的哥们报了个BUG.并且给出了一个解决办法,但是这个解决办法并不能解决我的问题. 但是微软的visualstudio组给的回应是外部无法控制的原因导致的.我去...... 环境: Win7 64位 VS2012 解决办法: 修改注册表: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rasman\Parameters 在“编辑”菜

Visual Studio 2015/2013安装失败:Microsoft Visual Studio 2015 Shell (Minimum) Interop Assemblies 安装时发生严重错误

由于安装VS2015时多次更改卸载重装等操作后,重新安装时出现该错误: Microsoft Visual Studio 2015 Shell (Minimum) Interop Assemblies 安装时发生严重错误 简直是无法继续了,网上搜索不到很明确的解决办法,查看日志文件得知错误码和错误信息: 0x80070643,Could not open key: UNKNOWN\Components\D2E60322F7884D115A04000972A8B18B\C5FEE661699FE09

Add more security in Visual Studio 2012

Compile flags: /GS: Stack protection from buffer overrun. /SDL: Subset of W3&W4 security warnings as errors. Use warning 4. /WX: Treat Warnings As Errors. Linker flags: /DYNAMICBASE: Randomize module base address to ensure that our code is at differe

Visual Studio远程调试监视器(MSVSMON.EXE)的32位版本不能用于调试64位进程或64位转储

在VS2013中调试Silverlight项目时,提示:无法附加.Visual Studio远程调试监视器(MSVSMON.EXE)的32位版本不能用于调试64位进程或64位转储.请改用64位版本. 解决方法很简单: 把调试按钮的调试程序Internet Explorer改成Internet Explorer2,就可以了.

Visual Studio发布Web项目报错:Unable to add &#39;xxx&#39; to the Web site. Unable to add file &#39;xxx&#39;. The specified file could not be encrypted.

背景 Visual Studio下的Web项目 现象 发布时遇到Unable to add 'xxx' to the Web site.  Unable to add file 'xxx'. The specified file could not be encrypted.的报错 原因 这些文件(文件夹)被设置为"加密".可能因为这些文件是从Internet上下载并复制到项目下的文件夹,在被下载前就已经被启用"加密"选项 这些文件(文件夹)来自于其他计算机并被锁定

Visual Studio中根据系统区分引用64位、32位DLL动态库文件的配置方法

原来使用Win7的32位系统,进行C#工程的开发,后来重装系统,换成了win7的64位系统 调试原来的工程,由于在其中引用了"SQLite"的32位的dll,导致在64为位下程序无法运行(但是编译可以通过) 后来通过修改工程文件(.csproj),在其中设置引用的条件,解决了问题 打开引用了SQLite的工程(例如叫做info)的工程文件(info.csproj),找到对SQLite引用的语句,类似如下的代码 代码如下: <Reference Include="Syst

Visual Studio 2013 编译 64 位 Python 的 C 扩展 (使用 PyObject 包装)

对于 32 位 Python 的 C 扩展,以前用过 mingW32 编译, 但是 mingW32 不支持 64 位 Python 的 C 扩展编译,详情可见 stackoverflow,这位前辈的大意如下, 以下介绍 Visual Studio 2013 编译 64 位 Python 的 C 扩展步骤: 1)准备 C 文件和包装文件, ExtDemo.c // Purpose: C code, for wrappered. #include <stdio.h> #include <st

visual studio 2015生成64位DLL文件

新建一个visual C ++  ->win32项目 点击生成->配置管理器新建一个64位debug位平台 hello.cpp程序代码如下: #include "stdafx.h" #include "jni.h" #include "com_magc_jni_HelloWorld.h" JNIEXPORT void JNICALL Java_com_magc_jni_HelloWorld_DisplayHello (JNIEnv *