Vector3 errors, Content errors, any many many more

I try to add accelerator movement to my Windows Phone Monogame application and this is what happens

Error 3
The type ‘Microsoft.Xna.Framework.Vector3’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553’.

Error 2 Cannot implicitly convert type ‘Microsoft.Xna.Framework.Vector3’ to 'Microsoft.Xna.Framework.Vector3

Here is the line

 private void UpdateUI(AccelerometerReading accelerometerReading)
 { 
        Vector3 acceleration = accelerometerReading.Acceleration; 
  }

I added the Monogame.Framework.WindowsPhone project, which includes class Vector3, doesnt work. I added the assembly Microsoft.Xna.Framework, shows the yellow triangle and a warning that

"Warning 5 The referenced component ‘Microsoft.Xna.Framework’ could not be found. "

The error was reported on MSDN site and no one responded. I found a smiliar problem, bo their solution doesnt work for me. Guys from stackoverflow sent me here.

The second error is even more depressing.
The line

Texture2D myTexture =Content.Load<Texture2D>("boat_done");

Is throwing
"An exception of type ‘System.NotImplementedException’ occurred in MonoGame.Framework.DLL but was not handled in user code

Additional information: The method or operation is not implemented."

Im 12 hours into this and still nothing. I dropped the Unity, I dropped the Cocos2d, I dropped the XNA, becouse of 1231231 errors reported by Visual Studio.

I fixed the texture error.
All you have to do is change XNB file Build Action in Properties to Content.

Sensors are under Windows.Devices.Sensors Since WP8.
Unfortunately the new class is a terrible source of garbage making it a bad choice for games in managed frameworks such as sharpDx,Monogame,etc.

The error lies in Vector3 class, the Devices.Sensors works ok, and Im not sure if there is any other way to implement the accelerator control in WP8 games.

check this, this may help you:

1 Like

I tried this earlier, didnt get any results. But now, I changed a couple of things and finally got it to work, thanks!
Here is what I did

I changed the line that gave all the errors to
XnaHelper.FauxVector3 accel = XnaHelper.XNAHelper.ExtractGravity(accelerometerReading);

And at the XnaHelper library I changed the ExtractGravity to

public static FauxVector3 ExtractGravity(AccelerometerReading reading) { return new FauxVector3(reading.Acceleration.X, reading.Acceleration.Y, reading.Acceleration.Z); }

Thanks again!

An exception of type ‘Microsoft.Xna.Framework.Content.ContentLoadException’ occurred in MonoGame.Framework.DLL but was not handled in user code
Additional information: Could not load agency_fb asset as a non-content file!

agency_fb.spritefont is in the Content file, yet i still get this error.
Is the font in wrong format?
I didnt generate the .spritefont file i just copy pasted it from someone else and changed some values to match mine, but I guess it shouldnt be the reason.
Is there any other way to load fonts into the monogame project?
There is no Add Item → New → SpriteFont file in my build for some reason.
the .fnt file is throwing the same exception.
Yes, I set Build Action to content and “copy if newer”.

Hi Morelin. Sounds like you are adding the .spritefont file to the game project and setting the build action to copy. That won’t work as it needs to be compiled to a .xnb first. Either use a vanilla Xna content project to generate the xnb file or use the fairly new Pipeline.exe tool: http://www.monogame.net/documentation/?page=Using_The_Pipeline_Tool

The game is almost finished and ready to publish, but it lacks a few things.

The main problem, which I cant fix since the first weeks of development.
I start the app, the main menu XAML apears, I click Play, and it navigates to the page with the initializing code in .cs file

_game = XamlGame<Game1>.Create("", this);

and the component in XAML file

< MediaElement x:Name="XNAWorkplace" Opacity="100" Margin="0,10,0,-10" Loaded="XNAWorkplace_Loaded"/>

No problem here, everything works fine. When you click the settings button, which is implemented via XAML, it navigates to another page. But when I try to go back by navigating to the GamePage again, the following error occurs

An exception of type 'System.NullReferenceException' occurred in SharpDX.Direct3D11.DLL but was not handled in user code
Additional information: Object reference not set to an instance of an object.

One may say - wow, thats a newbie error, you are using object that is not initialized, just initialize it.
The line that is throwing the error

spriteBatch = new SpriteBatch(GraphicsDevice);

GraphicDevice is initiated in game1 constructor and seems like the constructor is not called everytime the page is initialized even tough the Create is in the onNavigatedTo page method.

tl;dr - how to make the Xna component initialize more than once in the same run? That means - Menu_XAMLPage - > Play_XAMLPage -> GameOver_XAMLPage, try again -> Play_XAMLPage

Thanks for any help, I really appreciate it.

Do not navigate to diferent XAML page.
Use the Game State Management sample.
http://xbox.create.msdn.com/en-US/education/catalog/sample/game_state_management

That means I cant use XNA and XAML?
Welp, that means the app is not even at 5% of completion.
Whats the point of putting the Xna component in XAML page, I thought the whole point of Monogame is that it lets me use those together.

EDIT: FIXED
All you had to do to make navigating work is to add onUnload event handler - we need to unload the game everytime we exit it, so the constructor is called again.

in the GamePage constructor

 this.Unloaded += GamePage_Unloaded;

and the method

  private void GamePage_Unloaded(object sender, RoutedEventArgs e)
    {
  Deployment.Current.Dispatcher.BeginInvoke(() => _game.Dispose());
    }

WP has two basic project types, one with XAML for apps and one for Games with C++/DirectX.
The only reason MogoGame use the first is because it allows C#/Dot.Net. I don’t think the senario of working with multiple pages is suported and it’s not wise to reinitialize everything just for moving from page to page.

I am happy you made it work but you have to consider how this limits your options to port the game to other platforms. Also by using a state managment you will be able to provide faster/smoother transitions between pages.

1 Like

Its a one-try game like Flappy Bird or Square by Ketchapp, so the scenario of reinitializing everything is not that problematic, I just need to save the position and score to make it look like the game was just paused.
I dont know much about porting so Im not planning to port this game soon.

Ok, the game is almost finished.
The last thing is the loading/splash screen implemented in the monogame bundle.
I tried to find a file to replace the default loading screen but without success.

Where is the line that displays this animation? Is there a simpler way to just set the different image?