Closed Orujimaru closed 10 years ago
What platform are you on? XNB is required for those platforms that don't use the content pipeline. You have to use the content pipeline preprocessor project for iOS, Windows 8, etc. If you are on Android, then you have to compile your XNA game in VS then copy the XNB files to an Assets directory where you load them with the content manager. This works well.
It's important to know what TYPE of asset you are trying to load in this XNB file that is giving you the error. What type is it?
I think I should have mentioned that I'm using MonoGame 3.0 beta :)
I load both spriteFonts and textures as .xnb in Windows 7. This worked fine with 2.5.1, then I switched the dependencies to v 3.0 and now it throws NotYetImplemented errors. By the name of the error I assume this error is known and will be implemented. I just wanted to mention it in case it was forgotten. It's pretty important since it's the only way to load SpriteFonts (? I don't know if 3.0 can load .spriteFont files).
@Orujimaru
What is the exception call stack?
I get the same results when I change the dependencies in my current project and when I create a fresh MonoGame 3.0 template.
This is how it looks when I'm trying to load a SpriteFont as xnb:
System.NotImplementedException was unhandled Message=Metoden eller åtgärden har inte implementerats. Source=MonoGame.Framework.Windows StackTrace: vid Microsoft.Xna.Framework.Content.ContentManager.ReadRawAsset[T](String assetName, String originalAssetName) vid Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject) vid Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) vid Schism.Game1.LoadContent() i D:\Google Drive\My Stuff\Project Schism\Source\Schism\Game1.cs:rad 55 vid Microsoft.Xna.Framework.Game.Initialize() vid Schism.Game1.Initialize() i D:\Google Drive\My Stuff\Project Schism\Source\Schism\Game1.cs:rad 48 vid Microsoft.Xna.Framework.Game.DoInitialize() vid Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) vid Microsoft.Xna.Framework.Game.Run() vid Schism.Program.Main() i D:\Google Drive\My Stuff\Project Schism\Source\Schism\Program.cs:rad 16 vid System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) vid System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) vid Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() vid System.Threading.ThreadHelper.ThreadStart_Context(Object state) vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) vid System.Threading.ThreadHelper.ThreadStart() InnerException:
This is what I get when I'm loading a texture, I just noticed they are throwing different exceptions:
Microsoft.Xna.Framework.Content.ContentLoadException was unhandled Message=Could not load Texture.xnb asset! Source=MonoGame.Framework.Windows StackTrace: vid Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject) vid Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) vid Schism.Game1.LoadContent() i D:\Google Drive\My Stuff\Project Schism\Source\Schism\Game1.cs:rad 55 vid Microsoft.Xna.Framework.Game.Initialize() vid Schism.Game1.Initialize() i D:\Google Drive\My Stuff\Project Schism\Source\Schism\Game1.cs:rad 48 vid Microsoft.Xna.Framework.Game.DoInitialize() vid Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) vid Microsoft.Xna.Framework.Game.Run() vid Schism.Program.Main() i D:\Google Drive\My Stuff\Project Schism\Source\Schism\Program.cs:rad 16 vid System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) vid System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) vid Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() vid System.Threading.ThreadHelper.ThreadStart_Context(Object state) vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) vid System.Threading.ThreadHelper.ThreadStart() InnerException:
Well both Texture and SpriteFont are implemented in MonoGame 3. There is something else going on here.
What platform are you targeting?
Microsoft.Xna.Framework.Content.ContentLoadException was unhandled Message=Could not load Texture.xnb asset!
That exception is thrown if the content is not found. We should probably fix that to say just that... "file not found" and not the generic unhelpful message it says.
Still it leads me to what I think your bug is.
Are you doing this...
content.Load<Texture2D>("Texture.xnb");
... because that is incorrect. You never pass file extensions to ContentManager.Load()... it just wants the filename.
You are right I am passing the extension to ContentManager.
Removing the extension solved it, this confused me because I've always used the extension when loading content with MonoGame 2.5.1 and XNA in general. Thanks for the help!
About the stack call for the Texture2D, I was in a rush and took it from a new project where I forgot to copy the texture to the output directory.
This works well on windows but Mac gives me the "NotYetImplemented" error (using version 3.0). Is this a known error? and is there something to do about it. Or should I just revert back to an older version of MonoGame?
What type of resource are you trying to load? What is the callstack to the NotImplementedException?
We downgraded to MonoGame 2.5 and things started working again. However XML files still wont load through the content pipeline... Is this a known issue?
Scrap that. It works :)
I can add that I had trouble loading different types of resources until I set up a MonoGame Content Project, now everything loads perfectly. However, the only way I managed to reference a MonoGame Content Project to my MonoGame project was via a Windows Library Project, does anyone know if my application still is platform independent as long as I switch the XNA references in the Windows Library Project for MonoGame references?
@Orujimaru Yes that should be fine.
Close please @tomspilman Long dead issue.
When trying to load any kind of .xnb file a "NotYetImplemented" error is thrown.