在VS2012中创建64位项目时出现问题 [英] Issue while creating 64 bit project in VS2012

查看:175
本文介绍了在VS2012中创建64位项目时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的要求是在Visual Studio 2012中创建一个64位应用程序。我将项目属性中的目标平台更改为x64。



我可以看到当我将目标平台设置为任何CPU或x86时解决方案正常,但是在选择x64时它会在运行时给出以下错误。



错误是:

无法加载文件或程序集Demo64bitCheck或其中一个依赖项。试图加载一个格式不正确的程序



任何人都可以帮我解决这个问题。



谢谢

Hi,

My requirement is to create a 64 bit application in Visual Studio 2012. I changed the target platform in project properties to x64.

As I can see the solution works fine when I set target platform to Any CPU or x86, but on selecting x64 it gives me the following error on runtime.

The error is:
Could not load file or assembly 'Demo64bitCheck' or one of its dependencies. An attempt was made to load a program with an incorrect format

Can anyone please help me with this issue.

Thanks

推荐答案

没有理由将平台设置为特定的指令集架构任何CPU都可以工作。 .NET基于JIT编译,因此应用程序将在运行时确定的平台上执行。请参阅:

http://en.wikipedia.org/wiki/Instruction_set [< a href =http://en.wikipedia.org/wiki/Instruction_settarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Just-in-time_compilation [ ^ ]。



你只有在至少有一个程序集或非托管模块编译到某个特定体系结构时才需要使用其他平台。但在这种情况下,所有目标平台应该是一致的。例如,您可以将所有程序集编译为Any CPU,并将您的入门级程序集编译为某个特定的体系结构,例如。一些非托管模块被编译为。应用程序中使用的任何其他程序集都应编译为任何CPU或相同的体系结构。如果您在平台上有任何不匹配,它将无法工作。



此外,您应该了解x86将适用于任何64位平台,通过WoW64: http://en.wikipedia.org/wiki/WoW64 [ ^ ]。



与此同时, 64位平台彼此不兼容。没有只是64位平台,它们是不同的,不能混淆。请参阅:

http://en.wikipedia.org/wiki/Itanium [< a href =http://en.wikipedia.org/wiki/Itaniumtarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/X86-64 [ ^ ],

http://en.wikipedia.org/wiki/X86 [ ^ ]。



如果任何CPU有效,请使用它并考虑您的要求。 :-)



-SA
There is no reason to set the Platform to a particular instruction-set architecture it "Any CPU" works. .NET is based in JIT compilation, so the application will be executed on the platform determined during runtime. Please see:
http://en.wikipedia.org/wiki/Instruction_set[^],
http://en.wikipedia.org/wiki/Just-in-time_compilation[^].

You need to use other platforms only when you have at least one assembly or an unmanaged modules compiled to some particular architecture. But in this case, all target platforms should be consistent. For example, you could have all assemblies compiled to "Any CPU", and your entry-level assembly compiled to some particular architecture, because, for example. some unmanaged module is compiled to that. And any other assembly used in application should be compiled as "Any CPU" or to the same architecture. If you have any mismatch in the platforms, it won't work.

Also, you should understand that x86 will work on any of the 64-bit platforms, via WoW64: http://en.wikipedia.org/wiki/WoW64[^].

At the same time, the 64-bit platforms are incompatible with each other. There is no just "64-bit" platform, they are different and cannot be mixed up. Please see:
http://en.wikipedia.org/wiki/Itanium[^],
http://en.wikipedia.org/wiki/X86-64[^],
http://en.wikipedia.org/wiki/X86[^].

If "Any CPU" works, use just it and consider your requirement met. :-)

—SA


这篇关于在VS2012中创建64位项目时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆