[DUPLICATE/SOLVED] "This MGFX effect was built for a different platform!"

This thread is effectively a duplicate of the following thread: [SOLVED] Conditional compilation of pipeline Content based on Visual Studio project / platform

See there for details.

The short of it is, removing the “/platform” line from Content.mgcb seems to address this issue.

Hey all,

I released my game back in October last year and then went and took a 6 month contract to beef up the ol’ finances. I’m back at game development and working on a new game; however, there’s some updates I need to do to my previous title. I’m now getting the following exception at runtime while trying to load one of my shaders…

[0:] System.Exception: This MGFX effect was built for a different platform!
  at Microsoft.Xna.Framework.Graphics.Effect.ReadHeader (System.Byte[] effectCode, System.Int32 index) [0x0009d] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Graphics.Effect..ctor (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.Byte[] effectCode, System.Int32 index, System.Int32 count) [0x00007] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.EffectReader.Read (Microsoft.Xna.Framework.Content.ContentReader input, Microsoft.Xna.Framework.Graphics.Effect existingInstance) [0x00024] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.ContentTypeReader`1[T].Read (Microsoft.Xna.Framework.Content.ContentReader input, System.Object existingInstance) [0x00003] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T] (T existingInstance) [0x0002d] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T] () [0x00000] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T] () [0x00006] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T] (System.String assetName, System.Action`1[T] recordDisposableObject) [0x00080] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at Microsoft.Xna.Framework.Content.ContentManager.Load[T] (System.String assetName) [0x0005a] in <14285e7be6444bda94a4048e3cb68e5b>:0 
  at ArbitraryPixel.Common.ContentManagement.MonoGame.MonoGameContentManager.Load[T] (System.String assetName) [0x00001] in C:\ArbitraryPixel\Libraries\ArbitraryPixel.Common\ArbitraryPixel.Common.ContentManagement.MonoGame\MonoGameContentManager.cs:30 
  at ArbitraryPixel.Common.Graphics.MonoGame.Factory.MonoGameEffectFactory.Create (ArbitraryPixel.Common.ContentManagement.IContentManager contentManager, System.String assetName) [0x00001] in C:\ArbitraryPixel\Libraries\ArbitraryPixel.Common\ArbitraryPixel.Common.Graphics.MonoGame\Factory\MonoGameEffectFactory.cs:11 
  at ArbitraryPixel.CodeLogic.Common.Scenes.MainMenuScene.OnLoadAssetBank (ArbitraryPixel.Common.ContentManagement.IContentManager content, ArbitraryPixel.Platform2D.Assets.IAssetBank bank) [0x00458] in C:\ArbitraryPixel\Code Logic\source\CodeLogic\ArbitraryPixel.CodeLogic.Common\Scenes\MainMenuScene.cs:136 

This happens for Android only. The Windows build works fine.

I did some googling and the only thing I can find in relation to this is stuff having to do with MonoGame.Extended. I did have this in one of my base libraries, but removed it to see if it resolved the issue.

The strange thing is, if I make a brand new Android project and use the same shader, everything works fine. I’m currently using the latest released version of MonoGame (, as well as the most up to date PCL versions from NuGet for all my portable libraries.

Both my game and my test project are targeting Android 9.0 for their build. In my game, I do have a a shared content folder loaded by both Windows and Android, referenced by a linked directory. In my test project it’s just a full Android project. For my game, I did a full clean (and manual delete) of all bin/obj files, including all copied XNB files, so a previous version of a content build should not be present.

Has anybody encountered this before, or have any thoughts?

Oh, an interesting development…

So I was comparing the Content.mgcb files between my test project and my game project and noticed that there is a platform flag.

#----------------------------- Global Properties ----------------------------#


On my test project this is set to Android (as above) but on Windows it was set to Windows. As stated earlier, I link both my builds to the same content file, which in the past worked just fine.

It was nice in the past because I didn’t have to maintain two different content files for my builds, I could just use the same one. I could probably figure out some pre-build shenanigans to get back to a single content build file; however, I’m hoping that I don’t need to.

Is this something that’s changed with MonoGame 3.7? Is there something else I need to do now?

Thanks for any info or insights! :slight_smile:

@Trinith Not sure if anything has changed recently… but I recently solved a problem whereby I can now have the mgcb built for the appropriate platform based on the VS project.

See this thread for more details:

Hey, thanks for the reply! I’ll check into that… it sounds like it might actually be the problem. I did confirm that my project files for both Android and Windows have the appropriate platform set, so it sounds like the content build just isn’t respecting that anymore.

I wonder if this is a bug with 3.7… I never used to have this problem in 3.6. I’ll try this out and post back in a couple of days.

Hey, so I looked into the stuff from your thread. I went through the targets file and everything should have worked just fine. That platform thing, being pulled from the project file, is properly added to the command. The stuff that you did should have been redundant… so it’s kinda weird that it worked. Because of this, I think there might be something funky going on still… but I have a fix.

Since your thread predates mine, I’m just going to move discussion over to that and reply there. I’d consider this a duplicate of yours.

This issue happened to me and none of the answers above nor in the linked threads fixed it. I eventually found out that it was because one of the third party nuget packages I had added had a dependency on DesktopGL yet my own projects depend on WindowsDX. Removing the third party libary fixed it.