Vector2 compilation error

Topics: Developer Forum
Dec 31, 2007 at 5:13 AM
I get a compilation error from the FarseerExample project when set to Release mode. This is what I get:
Error 10 'Vector2' is an ambiguous reference between 'Microsoft.Xna.Framework.Vector2' and 'FarseerGames.FarseerPhysics.Mathematics.Vector2' C:\*******\FarseerPhysicsEngineWithSamplesForXNA_1.0.0.3\FarseerPhysicsDemos\DrawingSystem\LineBrush.cs 60 40 FarseerPhysicsDemosXBox360

Is there something I am doing incorrectly? I only extracted the project, opened it, then compiled it. I didn't modify anything else. Thanks!
Dec 31, 2007 at 8:34 PM
Are you compiling for Xbox360 or the Windows platform?
If you just want the windows platform to work, just remove the XBox360 project from the solution.

The reason you get this error, is because both Microsoft.Xna.Framework and the FarseerGames.FarseerPhysics.Mathematics namespace has a struct with the name Vector2. One way of solving this is to remove one of the namespace references. You can do this by removing the "using Microsoft.Xna.Framework;" from the top of the file.
This however, would break the build I think. (I can't verify this as i'm currently not on a computer with a compiler), this is because the namespace you just removed a reference to may be used by the file (LineBrush.cs). You can fix this by finding the line that uses the namespace and make a reference to the namespace, but this time using the fully qualified name like this: Microsoft.Xna.Framework.Vector2
Dec 31, 2007 at 11:03 PM
In the visual studio menu there is a drop down that default to Mixed Platform. Change it to x86 and all should be good. This is a known issue but I don't have anyway to set the default platform so it just has to be tolerated.
Jun 24, 2008 at 2:05 AM


Okay, I spent the better part of an hour attempting to figure out why my program couldn't find the system ( namespace and finally realized that the physics engine project is a silverlight project so it cannot reference the full .net system namespace.

This is significant for me because I am building a game server which is running on the full .net framework.  The game client is still silverlight, but most of the physics calculations are done on the server.  Are there any plans on porting this to .net entirely?


Jun 28, 2008 at 5:01 AM
I've got a project built for Windows and I created a copy for the 360 but I'm getting the 'Vector2' is an ambiguous reference between 'Microsoft.Xna.Framework.Vector2' and 'FarseerGames.FarseerPhysics.Mathematics.Vector2' error when I try to package the 360 version as a creator's club game, how do I fix this?
Jul 2, 2008 at 1:42 PM
I just downloaded the latest package and was able to get it to work using the instructions posted earlier. In Visual Studio, you have to change the "Solution Platforms" from "Mixed Platforms" (the default) to "Xbox 360" or "x86" for it to compile in Release mode.
Jul 3, 2008 at 8:38 PM
Okay, I've got my windows version of Farseer and my game set to x86 and Release. I add the farseer 360 project to my solution, I then create a 360 copy of my game. I then change the solution platform to Xbox 360. The farseer portion builds ok but the 360 version of my game bombs with the same 'ambiguous reference' error. I'm getting errors about the Vector2 thing in the LineBrush class that I copied from the demos. Simply changing the target platform is not working for me.
Jul 4, 2008 at 4:16 PM
Have you tried just building the project that you download from the site rather than pulling it apart and adding it to your own? The project as it is from the package should compile with no issues. You can then just include the binaries built from that project.

If you include a copy of LineBrush into your own project and it won't compile because of ambiguous references, then just remove any reference to the Farseer Vector2 class in that file and replace it with the XNA Vector2. I think those are only in there because of Silverlight.
Jul 10, 2008 at 3:34 PM
I downloaded the most recent version with the demos and tried building it. The windows version builds fine but the 360 version bombs with the same error I get in my game and yes, I am changing the solution platform when I build it. Could someone post a start to finish tutorial on how to build the farseer with examples project? Maybe I'm missing a step or something...

I wonder if there could something screwy with my dev environment.
Jul 10, 2008 at 8:41 PM

I've just downloaded and compiled the SDK ( I had the Vector2 problem. The solution lies in the project settings. The Vector2.cs file starts with this:

if (!XNA)

Searched around a bit and the windows version of the lib defines the XNA symbol, but the xbox version doesn't.  Under the xbox version settings juat add XNA, and it is going to compile.

Hope this helps.

Feb 5, 2009 at 11:39 PM
I was confused when I got the same error, so a heads up:

If you use the .dll for a reference in your project, make sure it (the .dll) was compiled under the x86 release.

I noticed when I changed the release type, the .dll was named FarseerProject instead of FarseerPhysics, although it probably doesn't matter.

THere are ways around this problem without explicit references or deleting structs!
Feb 6, 2009 at 2:07 AM
When i converted my project to the xbox, i had the same problem (i think...) so i just removed all of the #if (!XNA) (then the references to the farseer math stuff) things i could find... Works just fine for me!
Feb 6, 2009 at 1:56 PM
@Shpaidaman: I've renamed the Farseer Physics XNA brand assembly to FarseerPhysics instead of FarseerProject. Thanks for pointing that out.

The files Vector2, Vector3, Matrix and MathHelper should not be in the XNA release. They are already included in the XNA Framework so its safe to remove them.

@RogueCommanderIX: Does this happen to the latest release too? I fixed a Xbox build error in 2.0.1 but there might be more.
Feb 7, 2009 at 7:21 AM
Well im not 100 percent that that was the error i was having but i think so... As i recall it was with 2.0.1 though...
Feb 7, 2009 at 1:40 PM
It would be great if you could reproduce the error. I'm on a x64 architecture and my configuration works, but it might not on 32bit systems.
Feb 8, 2009 at 4:16 AM
As i recall, i just created a copy for the Xbox. Then you get tons of the above error. If im wrong though, please correct me.