Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

c# - Visual Studio designer in x64 doesn't work

In Visual Studio 2010 64bit I can't design my forms.
I keep getting this warning (and error):

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.

This only happens with when I compile for x64 ... in x86 the designer works well.

Just want to be clear that I NEED the project to work on x64 because a lot of the project's components are compiled in x64 and won't work if the forms are in x86.

Has anyone else encountered this and found a solution ?

question from:https://stackoverflow.com/questions/5378919/visual-studio-designer-in-x64-doesnt-work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I can repro your problem by creating a WPF application with a user control (put the user control on the wpf app, and build x64).

Here's my guess as to what's going on:

Visual Studio is a 32-bit application and the WPF designer has to load referenced assemblies (you see that behavior all of the time when you use user controls, where you have to rebuild to get the designer to update). Windows does not support a sharing between 32-bit and 64-bit - you have to have either a 32 bit app or a 64-bit app, period, no sharing.

Since the WPF designer is 32-bit, the assemblies need to be 32 bit.

Here is a possible solution:

Design your app with the "Any CPU" option. This will cause your code to JIT to 32-bit on 32-bit platforms and 64-bit on 64-bit platforms.

  • The designer will work in "any cpu" because the assemblies get jitted to 32-bit.
  • When you need to debug 64-bit specifically, switch your build configuration to 64-bit (knowing that you must switch back to "32-bit or "any cpu" do form design)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...