1

I am creating a MonoGame Project via the NuGet packages. I started with a blank project and ran "Install-Package MonoGame" in the Package Manager Console. Afterwards I copied all my old code, changed the namespace to the new project name, and since then I am having strange build issues with Visual Studio, that don't go away after restarting VS or Rebuilding the Solution.

All of them have to do with Vector2 objects. I have had to create an extension method to access Vector2.X because VS could not find a definition for X within Vector2, even though if I hit F12 it takes me straight to Vector2.X. I've had to create a static method to create Vector2 instances because "new Vector2(x, y)" is an invalid argument for a method that needs Vector2 objects as parameters. Lastly, I have this line of code:

PhysicsBody.Position = Extras.ToSimUnits(new Vector2(value.X, value.Y));

And for it I get the error "Instance Argument: cannot convert from 'Microsoft.Xna.Framework.Vector2' to 'Microsoft.Xna.Framework.Vector2'". How is this even possible? I know I can continue adding static methods to do simple things that for some reason cause build errors until all the Vector2 stupidity is gone, but is there a fix that will make this work correctly?

neowinston
  • 7,584
  • 10
  • 52
  • 83
einsteinsci
  • 1,137
  • 1
  • 8
  • 22

1 Answers1

1

MonoGame is most likely referencing a different version of XNA, or has used the same namespace for an alternate implementation to minimize code impact to end developers.

See @ayls answer to this similar question Monogame Ambiguous Vector2 for an approach.

Actually, this answer from @Andrew Russell looks even more authoritative Ambiguous reference between MonoGame & Microsoft.XNA.Framework namespaces

Community
  • 1
  • 1
Mark Larter
  • 2,343
  • 1
  • 27
  • 34
  • I am now getting the error "Thy type `Microsoft.Xna.Framework.Vector3` is defined in an assembly that is not referenced. You must add a freference to assembly `Microsoft.Xna.Framework`, Version=4.0.0.0, Culture=neutral, PublicKeyToken=blahblahblah". I have tried using Monogame's beta installer (that they make really hard to find), and after restarting the process of creating a project (this time using MonoGame templates), copying code files (but not settings), and trying to build, I get the same exact problems with Vector2. What I don't understand is that it's complaining about Vector3 now. – einsteinsci Apr 16 '14 at 19:22