# XNA Framework Reach profile does not support separate alpha blend

Yesterday I released my app 'Pic Words' to the windows phone store. It is an Silverlight/XNA app that runs on Windows Phone 7.1 & 8. I have BugSense incorporated into my app. Today I started receiving a lot of crash reports emanating exclusively from the 8.0.10211.0 version of Windows Phone 8. I could not replicate the issue since I do now currently own a Windows 8 phone and the emulator is running OS version 8.0.9903.0, which I don't think can be changed. The error from BugSense is as follows:

XNA Framework Reach profile does not support separate alpha blend. BlendState.ColorDestinationBlend and AlphaDestinationBlend must be set to the same value.

Stack Trace:

at Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(String message, Object arg1, Object arg2) at Microsoft.Xna.Framework.Graphics.BlendState.Bind(GraphicsDevice device) at Microsoft.Xna.Framework.Graphics.GraphicsDevice.set_BlendState(BlendState value) at Microsoft.Xna.Framework.Graphics.SpriteBatch.SetRenderState() at Microsoft.Xna.Framework.Graphics.SpriteBatch.End() at GlobalEngine.Base.SpriteBatchManager.ResumeSpriteBatch() at GlobalEngine.Base.SpriteBatchManager.Begin(SpriteBatchParams spriteBatchParams) at GlobalEngine.Base.SpriteBatchManager.Begin(Rectangle scissorArea) at GlobalEngine.Base.SpriteBatchManager.Begin() at FourWords.Screens.GameScreen.Draw(Color tint) at GlobalEngine.ScreenUtils.ScreenManager.Draw(Color tint) at GlobalEngine.Base.Engine.Draw() at FourWords.GamePage.OnDraw(Object sender, GameTimerEventArgs e) at Microsoft.Xna.Framework.GameTimer.RaiseDraw(GameTimerEventArgs gameArgs) at Microsoft.Xna.Framework.GameDispatcher.RunFrame() at Microsoft.Xna.Framework.GameDispatcher.OnTick(Object sender, EventArgs e) at MS.Internal.DirectRendering.OnGameUpdate(Object sender, EventArgs e) at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)

GlobalEngine is just my library of basic classes like screen management and so on. SpriteBatchManager is a class I created also for managing the spritebatch.

I Begin the spriteBatch with the following parameters:

SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None

Additionally, I manipulate the graphic device as follows in the GamePage.xaml:

protected override void OnNavigatedTo(NavigationEventArgs e){
// Set the sharing mode of the graphics device to turn on XNA rendering
SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);
SharedGraphicsDeviceManager.Current.PreferredBackBufferFormat = SurfaceFormat.Color;
SharedGraphicsDeviceManager.Current.ApplyChanges();
//other unrelated code....}


• I can't tell you the exact issue, but I'm 99% sure it originates in your BlendState.AlphaBlend. Looks like something is going wrong on the older version of WP8. What you could do is do a readout of all the members on a working demo, like your emulator, then create a custom BlendState with the exact same settings and use that in place of BlendState.AlphaBlend. – William Mariager Jul 17 '13 at 3:39
• In an attempt to resolve this as fast as possible, I've attached an answer. I hope it solves your problems. – William Mariager Jul 17 '13 at 3:49
• I just found out i have a phone with that exact os version. I might be able to help you out with a bit of testing. – William Mariager Jul 17 '13 at 4:02

I think the issue is possibly a bug in the older versions of Windows Phone 8.

The blend state seems to be borked so you need to create a custom one that you know works.

private BlendState alphaBlend = new BlendState()
{
AlphaSourceBlend = Blend.One,
ColorDestinationBlend = Blend.InverseSourceAlpha,
ColorSourceBlend = Blend.One,
BlendFactor = Color.White,
ColorWriteChannels = ColorWriteChannels.All,
};


This is a direct copy of a functioning BlendState.AlphaBlend from a working Reach profile Silverlight application I have.

You should declare it in the class that needs it, in the constructor or Initializer as it only needs to be done once. Then change your function from this ...

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None)


... to this ...

spriteBatch.Begin(SpriteSortMode.Deferred, this.alphaBlend, SamplerState.LinearClamp, DepthStencilState.None)


This way you avoid using the built-in one that seems to have issues, and instead you use one that has been tailored to work. This is definitely a workaround but unless you want to force your players to update, it's the only solution.