Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Stud
2015-01-19 23:23
597 查看
今天在给Winform的主界面添加Windows Forms Control Library的控件时遇到了一个问题。
之前都是使用32位程序的,这次从开发阶段开始,就使用的64位编译环境,才遇到了这么一个棘手的问题。
可以概括为Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE。
经过调研,微软给出的解释是“ 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.”
解决方法就是绕过界面设计器,添加引用时【Projects】里将整个工程都给添加引用进来,而不是使用【Browse】加入dll,怀疑是动态链接和静态链接的关系,有待调查。这时候,Form.h中通过手动添加代码,已经可以在主界面上显示自有的控件了,代码主要包括:
1) 添加引用;
2) 类中private下声明:VideoBrief::VideoBriefControl ^ VideoBriefControl1;
3) InitializeComponent中gcnew:VideoBriefControl1= gcnew VideoBrief::VideoBriefContro l();
4) 设置属性:
//
//VideoBriefControl1
//
VideoBriefControl1->BorderStyle= System::Windows::Forms::BorderStyle::Fixed3D;
VideoBriefControl1->Name= L"VideoBriefControl1";
VideoBriefControl1->Dock= System::Windows::Forms::DockStyle::Fill;
5) Form中进行add:this->Controls->Add(VideoBriefControl1);
但是!Form1的界面设计器还是不能显示的,这就需要将没添加代码的Form文件备份一下,需要修改主界面时,直接替换掉。
之前都是使用32位程序的,这次从开发阶段开始,就使用的64位编译环境,才遇到了这么一个棘手的问题。
可以概括为Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE。
经过调研,微软给出的解释是“ 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.”
解决方法就是绕过界面设计器,添加引用时【Projects】里将整个工程都给添加引用进来,而不是使用【Browse】加入dll,怀疑是动态链接和静态链接的关系,有待调查。这时候,Form.h中通过手动添加代码,已经可以在主界面上显示自有的控件了,代码主要包括:
1) 添加引用;
2) 类中private下声明:VideoBrief::VideoBriefControl ^ VideoBriefControl1;
3) InitializeComponent中gcnew:VideoBriefControl1= gcnew VideoBrief::VideoBriefContro l();
4) 设置属性:
//
//VideoBriefControl1
//
VideoBriefControl1->BorderStyle= System::Windows::Forms::BorderStyle::Fixed3D;
VideoBriefControl1->Name= L"VideoBriefControl1";
VideoBriefControl1->Dock= System::Windows::Forms::DockStyle::Fill;
5) Form中进行add:this->Controls->Add(VideoBriefControl1);
但是!Form1的界面设计器还是不能显示的,这就需要将没添加代码的Form文件备份一下,需要修改主界面时,直接替换掉。
Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE
相关文章推荐
- The Best Way to Use a 32-Bit DLL Library in a 64-Bit Platform
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- Adding Assemblies to the Visual Studio "Add Reference" Dialog(收集)
- How to use the System Restore API to save and to restore system data in Visual C++
- [转]Add “Atlas” controls to the toolbox
- HOWTO: Get the project flavor (subtype) of a Visual Studio project from an add-in
- How to tell if you’re running the 32 bit or 64 bit kernel in Mac OS X Snow Leopard
- How to Delete From or Add Resource to OCR in Oracle Clusterware (文档 ID 1069369.1)
- Cannot make a static reference to the non-static method setInAnimation(Animation) from the type View
- Unsaved documents cannot be cut or copied to the clipboard from the Miscellaneous Files project
- How to add HTML code to the clipboard by using Visual Basic Or VBA
- How to Increase the Memory Limit for 32-bit Applications in Windows 64-bit OS
- [Yii Framework] How to run cron job (or use command) in the server with yii framework
- How To Use the System Tray Directly from Visual Basic
- The report server cannot decrypt the symmetric key that is used to access sensitive or encrypted data in a report server databas
- Use the Stack mehod and a temporary Stack to retrieve entries from the Stack source and add
- TRIGGERS :Cannot use text, ntext, or image columns in the 'inserted' and ' deleted' tables.
- Server Error in '/' Application. Cannot use a leading .. to exit above the top directory
- Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE
- You receive a C4226 or a C4236 error message when you compile code to contain the keyword in 32-bit Visual C++(ZZ)