3.2 on Windows Phone 8 just shows black screen

Same here. Also, if I add the line

SoundEffect.MasterVolume = 0.3f;

app crashes.

An exception of type ‘System.NullReferenceException’ occurred in MonoGame.Framework.DLL but was not handled in user code

I tested it with Visual Studio Express 2013 for Windows, but I always get a black screen. What is wrong?
Black screen

If your game is portrait then on GamePage.xaml you can swap the Grid for the DrawingSurfaceBackgroundGrid as described in the comment at the bottom of the template. That is working, but for some reason the Grid version which you need if you want to support a landscape game doesn’t seem to be working.

Thanx. The portrait mode works with this code.

<phone:PhoneApplicationPage
x:Class="GameName1.GamePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="False">
<DrawingSurfaceBackgroundGrid x:Name="XnaSurface" Background="Transparent">
<MediaElement></MediaElement>
</DrawingSurfaceBackgroundGrid>
</phone:PhoneApplicationPage>
1 Like

Just do what iv done and make the game in portrait and rotate everything to landscape by render to a back buffer then rotate and render to screen.

 RenderTarget2D BackBuffer;

then in your Intiialize()

//the size of the backbuffer
BackBuffer = new RenderTarget2D(GraphicsDevice, 1280, 720);

Then in your draw

GraphicsDevice.SetRenderTarget(BackBuffer);
//enter your draw code here
   GraphicsDevice.SetRenderTarget(null);
        gameBatch.Begin();
        gameBatch.Draw(BackBuffer, new Vector2(360, 640), null, Color.White, MathHelper.PiOver2, new Vector2(640,360), 1f, SpriteEffects.None, 0f);
        gameBatch.End();

MathHelper.PiOver2 will rotate one way and -MathHelper.PiOver2 will rotate the other way

you just need to work out the touch points as the will still report in portrait mode.

EDIT:
Of course you will need to handle the different size of screens, this code is only for 1280x720 as I haven’t got round to auto scaling for all screen sizes.

EDIT2:
Use the above code provided by Fox​9 to make the game run in portrait mode.

Yes, that could be a way to do it, but it is very ugly. Also, it nukes your performance because you’re basically drawing everything twice. The DrawingSurface should work (although also lowering performance)… There’s a problem with graphics device at these lines:

// Create the Direct3D 11 API device object and a corresponding context.
            using (var defaultDevice = new SharpDX.Direct3D11.Device(SharpDX.Direct3D.DriverType.Hardware, creationFlags, featureLevels))
                _device = defaultDevice.QueryInterface<SharpDX.Direct3D11.Device1>();

I’m using VS2012 Pro and I get the blank screen using the standard Landscape DrawingSurface

I noticed that the call to

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

will enter the Constructor of Game1 but the other methods like Initialize(), LoadContent() or Update() and Draw() are never called

I also downloaded the Platform2D sample (converted from XNA to monoGame) and this runs fine even in Landscape mode

Hello, guys!
I solve this problem by this way:
I created a new project called “Windows Phone XAML and Direct3D App”, then I deleted all code that related to cpp project in my solution and add MonoGame.Binaries references with Nuget.
After that I don’t have black screen and game works with any screen orientations!

I used VS2013. I suppose that MonoGame 3.2 Installer have defective Windows Phone 8 template.

MainPage.xaml

<Grid x:Name="LayoutRoot" Background="Transparent">
    <DrawingSurface x:Name="DrawingSurface" />
    <MediaElement Volume="1"/>
</Grid>

MainPage.xaml.cs

MyGame _game;
public MainPage()
{
    InitializeComponent();
    _game = XamlGame<MyGame>.Create("", this);
}
2 Likes

Thank you MiShu it works :slight_smile:

You’re welcome :wink: I also try to do the same thing with Windows Phone App template and it also work :smiley: But you need to specify platform x86 or ARM for Emulator or Device respectively in the solution properties.

So what is the difference between the original template and mono template? We need a new template then… What can I do to fix my app? (it is well off into development…)

EDIT: I tried now making my own template as you said from xaml+direct3d and it doesn’t load… Can you upload your project?

You can get template here https://onedrive.live.com/redir?resid=24923400704D0887!3539&authkey=!AAwQxeoQwb_cmhk&ithint=file%2C.zip

3 Likes

MiShu, your template worked like a charm–and I was one step away from deleting my MonoGame downloads for the sixth time and giving up on this whole toolkit as an unusable, non-functional piece of junk. So thank you!

I have this problem too. So the Windows 8 template is not working?

@bangclash it is working fine. Just the installer version of templates are broken, they are fixed on the Nuget.

For fixing the problem for Windows Phone 8, you just need the use nuget and install new MonoGame temp ( with dll’s and all ).

Code : Install-Package Monogame

But you have to do this very carefully, it will ask you to replace Game1.cs and some other files. Do this only if you have empty Project.

PS : Let the nuget change all files exept Game1.cs

1 Like

@semihmasat, I open my existing project and installed monogame through nuget and everything works. Thx.

You’re welcome.
Glad that worked for you.

for me, reinstall monogame using package manager console:
PM> Install-Package MonoGame
solve the problem

That worked perfectly for me, fixed the same problem as OP.

Thankyou thankyou thankyou thankyou.

This thread has just about saved me from topping myself.