无法在x64下构建UserControl

Tha*_*lia 2 vb.net 64-bit user-controls build

我正在尝试解决包含UserControls的VB.NET项目(实际上,其中一些显示相同的问题).我试图让他们在x64下构建,但这是不可能的.在x86或AnyCPU中,UserControl构建并显示在工具箱中,因此我可以在需要它的表单中添加或修改它.在x64中,控件从工具箱中消失,我在构建期间收到警告(当前项目构建虽然),我看不到任何表单 - 我收到错误(请参见下文) - 以及需要项目的项目作为导入的表单不会构建.当我研究这些UserControl是什么,以便我可以从头开始重建它们时,我从一本书中下载了代码 - 很棒的学习工具,但我得到了同样的错误:

Could not find type 'Chap15SampleCode.ListSelector'.  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 using settings for your current platform or Any CPU.

The variable 'ListSelector1' is either undeclared or was never assigned.
Run Code Online (Sandbox Code Playgroud)

我也收到警告,不知道如何处理它们:

Possible problem detected while building assembly 'Chap15SampleCode': Referenced assembly 'mscorlib.dll' targets a different processor
Possible problem detected while building assembly 'Chap15SampleCode': Referenced assembly 'System.Data.dll' targets a different processor
Run Code Online (Sandbox Code Playgroud)

我检查并发现System.Data作为参考在c:\ Windows\Microsoft.NET\Framework ...(如果我将目标框架更改为4.0,参考是在c:\ ProgramFiles(x86)...那是我的项目有什么......我试图改变它因为x86,我不能,我在ProgramFiles(x86)中有其他一些我认为可能是问题?)
重新安装VS2010,重新安装Windows - 做了同样在btw之前 - 但我确实有一个干净的系统所以我不能责怪它.
如果我能让这个简单的项目工作,我希望真正的项目很容易 - 请帮我弄清楚这是什么.谢谢.

Han*_*ant 7

您已将项目中的平台目标设置更改为x64.这不适用于生成DLL的任何项目.使用DLL的进程的实际位数由启动进程的EXE确定.或者运行DLL的主机,Visual Studio的情况是32位进程.DLL没有什么可以强制执行的,它只能拒绝加载.这就是你看到的情况.

将设置更改回AnyCPU,以便UserControl在任何进程中都能正常工作,无论其位数如何.包括VS设计师.Project + Properties,Build选项卡.对于VB.NET,它位于"编译"选项卡的"高级编译选项"按钮中.