Ambiguous Reference

I am trying to port my XNA Windows Phone 7 app to Windows Phone 8. To begin with I want to port my WP7 library project, so I created a Windows Phone 8 library project, referenced the Monogame 3.0.1 dll from program files, and copied over all the code. But now I am getting errors with all basic XNA types like Vector2 or Color. The error is “Cannot resolve symbol ‘Vector2’, Ambiguous Reference” and Resharper offers me to resolve this ambiguous reference by choosing between Microsoft.Xna.Framework.Vector2 or Microsoft.Xna.Framework.Vector2. But both are the same and choosing either does nothing. Cant figure the cause or the fix…

did you remove the xna reference?

I had the problem, but could not find a real solution.

The problem is that the Windows Phone 8 SDK assemblies refer to the original XNA assemblies and rely on Vector2, Vector3 and Color struct.

This blogpost explain how to setup a WP8 project which excludes original XNA assemblies. If your work with nightly builds of MonoGame 3.2 or with the nuget package, this fix should already be in your project file.

However, if you use an assembly which refers to the original XNA (I think about Microsoft.Devices for Accelerometer), you will still run into this conflict. For this particular case, a haven’t found a solution and had to workaround this by calling only events and methods which don’t work with Vector3.

Thanks for the replies. Following the NuGet instructions in your link, I created a test WP8 library project and Installed the MonoGame 3.0.1 or 3.1.3 packages from NuGet but that didnt fix the reference problem. The linked post says I dont need to tinker with the .csproj and can instead just let the Nuget package fix the reference problem.

:confused:

Did you checked if your .csproj file contains the following lines?

  <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'" />
1 Like

No it doesnt have them, and even after putting them in myself, VS still cant find the definition of Texture2D for example.
I am merely creating a WP8 lib project and then installing nuget ‘Install-Package MonoGame.Binaries’ and then declaring Texture2D for testing. I am not sure what am doing wrong.

What @mrhelmut is the normal fix for the “Ambiguous Reference” issue on WP8.

You should slow down, double check, and triple check that you are doing that correctly. It needs to be added to all your projects that reference MonoGame.