问题描述
我遇到一个问题,就是我不断在Monogame和XNA库之间出现歧义错误.无论我做什么,我都无法编译它.我已经从计算机上删除了XNA,但错误仍然存在.完整的错误是:
I am having an issue where I keep getting ambiguity errors between Monogame and XNA libraries. No matter what I do, I cannot get it to compile. I have removed XNA off my computer and yet the error still persists. The full error is:
Error 4 Argument 1: cannot convert from 'Microsoft.Xna.Framework.Vector2 [c:\Program Files (x86)\MonoGame\v3.0\Assemblies\WindowsPhone\x86\MonoGame.Framework.dll]' to 'Microsoft.Xna.Framework.Vector2'
在诸如以下的行上
EngineGlobal.world = new World(new Vector2(0,9.8f), false);
有人对消除冲突有任何建议吗?我希望继续在Monogame而不是XNA上进行开发,因为该代码将被移植到Android,iPhone等上的MonoGame环境中.
Does anyone have any suggestions on how to get rid of the conflict? I would like to continue to develop on monogame rather than XNA since the code will be ported into MonoGame environments on Android, iPhone, etc.
任何帮助将不胜感激!
推荐答案
我的答复有点晚,但是如果您查看MonoGame项目模板的作用,您会发现csproj文件中定义了一个额外的构建目标.
A bit late with my reply, but if you look at what MonoGame project templates do, you will find that there is an extra build target defined in csproj file.
就我而言,添加以下内容:
In my case adding this:
<Target Name="MonoGame_RemoveXnaAssemblies" AfterTargets="ImplicitlyExpandTargetFramework">
<Message Text="MonoGame - Removing XNA Assembly references!" Importance="normal" />
<ItemGroup>
<ReferencePath Remove="@(ReferencePath)" Condition="'%(Filename)%(Extension)'=='Microsoft.Xna.Framework.dll'" />
<ReferencePath Remove="@(ReferencePath)" Condition="'%(Filename)%(Extension)'=='Microsoft.Xna.Framework.GamerServices.dll'" />
<ReferencePath Remove="@(ReferencePath)" Condition="'%(Filename)%(Extension)'=='Microsoft.Xna.Framework.GamerServicesExtensions.dll'" />
<ReferencePath Remove="@(ReferencePath)" Condition="'%(Filename)%(Extension)'=='Microsoft.Xna.Framework.Input.Touch.dll'" />
<ReferencePath Remove="@(ReferencePath)" Condition="'%(Filename)%(Extension)'=='Microsoft.Xna.Framework.MediaLibraryExtensions.dll'" />
</ItemGroup>
使用含糊不清的引用的csproj解决了该问题.
to the csproj with ambigious references solved the problem.
这篇关于Monogame big昧Vector2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!