针对普通Visual Studio 2012项目中的XNA框架 [英] Target the XNA framework in ordinary Visual Studio 2012 project

查看:104
本文介绍了针对普通Visual Studio 2012项目中的XNA框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#XNA宿主项目,一个F#客户端项目将包含我的所有功能.它不会构建,因为F#项目引用了XNA项目不同意的mscorlib.dll和System.dll(实际错误-嗯,这确实是警告,我认为应该是 是一个错误-位于文章的底部).如何告诉F#项目以实际的XNA平台(特别是Xbox 360)为目标?

I have a C# XNA host project, with an F# client project that will contain all my functionality. It won't build because the F# project has references to mscorlib.dll and System.dll that the XNA project doesn't agree with (the actual error -- well, its really a warning that in my opinion should be an error -- is at the bottom of the post). How can I tell the F# project to target the actual XNA platform (specifically for the Xbox 360)?

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3268: The primary reference "\\vmware-host\Shared Folders\Projects\FSharp\Whirlygigs\Whirlygigs.Lib\bin\Debug\Whirlygigs.Lib.dll" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "\\vmware-host\Shared Folders\Projects\FSharp\Whirlygigs\Whirlygigs.Lib\bin\Debug\Whirlygigs.Lib.dll" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=***".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3268: The primary reference "\\vmware-host\Shared Folders\Projects\FSharp\Whirlygigs\Whirlygigs.Lib\bin\Debug\Whirlygigs.Lib.dll" could not be resolved because it has an indirect dependency on the framework assembly "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "\\vmware-host\Shared Folders\Projects\FSharp\Whirlygigs\Whirlygigs.Lib\bin\Debug\Whirlygigs.Lib.dll" or retarget your application to a framework version which contains "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=***".

推荐答案

您遇到的问题是,您的一个项目针对Windows版本的.NET Framework(mscorlibSystem),而另一个您的项目针对该框架的Xbox 360版本.而且,基本上,您不能将针对不同核心框架的程序集链接在一起.

The problem that you are having is that one of your projects is targeting the Windows versions of the .NET Framework (mscorlib, System) and one of your projects is targeting the Xbox 360 versions of the framework. And, basically, you cannot link together assemblies targeting different core frameworks.

我猜您的F#项目针对的是Windows版本的程序集. 您需要做的是让您的F#项目以Xbox 360参考程序集为目标.

I'm guessing that your F# project is targeting the Windows versions of the assemblies. What you need to do is get your F# project to target the Xbox 360 reference assemblies.

(请注意,我从来没有自己做过-所以我的回答只是您可以尝试的事情的清单.)

(Note that I've never done this myself - so my answer is just a list of things you could try.)

供您参考,这些参考程序集默认情况下安装到C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Xbox360\

For your reference, these reference assemblies are installed by default to C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Xbox360\

首先,您可以尝试使用可移植类库.我听说过与此相关的报道.

First of all, you could try using the Portable Class Library. I've heard mixed reports about this.

我可能会用一些手动的MSBuild技巧来做到这一点. Visual Studio项目文件 是MSBuild文件(XML).您可以在文本编辑器中将其打开并使用它.您会注意到XNA项目导入了以下文件:

The way I would probably do this is with some manual MSBuild trickery. A Visual Studio project file is an MSBuild file (which is XML). You can open it up in a text editor and play with it. You'll notice that an XNA project imports the following file:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />

因此,您可以尝试简单地将导入内容添加到项目文件中(以及其他一些XNA配置,例如<XnaPlatform>,放在适当的位置). 可能可以解决问题.

So you could try simply adding that import to your project file (and maybe some of the other XNA configuration, like <XnaPlatform>, in the appropriate place). That might do the trick.

如果没有,您实际上可以查看这些文件(它们位于C:\Program Files (x86)\MSBuild\Microsoft\XNA Game Studio\v4.0)并尝试找出它们用于设置框架程序集路径的内容.我对MSBuild不够了解,不能肯定地说.

If not, you could actually look at these files (they're at C:\Program Files (x86)\MSBuild\Microsoft\XNA Game Studio\v4.0) and try and figure out what they're using to set the path for framework assemblies. I'm not knowledgeable enough with MSBuild to say for sure.

否则,您可以对其进行暴力破解.您可以通过将其添加到<PropertyGroup>:

Otherwise, you could just brute-force it. You can turn off the built-in referencing of the core frameworks by adding this to a <PropertyGroup>:

<NoStdLib>true</NoStdLib>

然后手动设置每个引用的路径.所以你要改变这个:

And then manually set the paths for each reference. So you would change this:

<Reference Include="mscorlib" />

对此:

<Reference Include="mscorlib">
  <HintPath>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Xbox360\mscorlib.dll</HintPath>
</Reference>

对于所有其他参考,依此类推.以前我在使用这种最后一种方法方面很成功,因为它可以执行类似的操作(手动更改目标框架).

And so on for all the other references. I've previously had success with this last method, for doing something similar (manually changing the target framework).

这篇关于针对普通Visual Studio 2012项目中的XNA框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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