x64中的Visual Studio设计器不起作用

在Visual Studio 2010 64位中,我无法设计表单。
我一直收到这个警告(和错误):

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

这只发生在我为x64编译时……在x86中,设计师运行良好。

只是想明确我需要项目来处理x64,因为很多项目的组件都是用x64编译的,如果表单是在x86中则无法工作。

有没有其他人遇到这个并找到了解决方案?

我可以通过使用用户控件创建WPF应用程序来重新解决您的问题(将用户控件放在wpf应用程序上,然后构建x64)。

这是我猜测发生了什么:
Visual Studio是一个32位应用程序,WPF设计器必须加载引用的程序集(您在使用用户控件时始终会看到该行为,您必须重新构建以使设计器更新)。 Windows不支持32位和64位之间的“thunk” – 您必须是32位应用程序或64位应用程序,期间,不共享。

由于hte WPF设计器是32位,因此程序集需要为32位。

这是一个可能的解决方案:使用“任何CPU”选项设计您的应用程序。 这将使您的代码在32位平台上的JIT为32位,在64位平台上为64位。

  • 设计人员将在“任何cpu”中工作,因为程序集会被assembly到32位。
  • 当你需要专门调试64位时,将你的构建配置切换到64位(知道你必须切换回“32位或”任何cpu“做表单设计)

这是VS2008和VS2010中的一个错误。

这是错误报告:

http://connect.microsoft.com/VisualStudio/feedback/details/646328/the-designer-could-not-be-shown-with-platform-x64

似乎还没有解决这个问题。

Microsoft提出的解决方案是将基类移动到单独的程序集,使用AnyCPU或x86编译(如果您的实际项目必须是x64)。

不幸的是,这适用于所有基类:如果您的inheritance是FormCFormBFormA ,那么如果您想在设计器中编辑FormC ,则FormA FormB必须位于(外部)32位程序FormC

当然,这也适用于UserControls! 我希望在我们的团队决定转移到64位之前我已经知道这一点 – 更改编译选项的通知本来不错,微软……

微软的这几个链接解释了这个问题:我恢复它们:它是VisualStudio的一个限制,因为它没有x64版本。

http://connect.microsoft.com/VisualStudio/feedback/details/583872/windows-forms-designer-cant-design-form-inherited-from-form-in-x64-assembly

http://support.microsoft.com/kb/967050