Intermittent "The content file was not found" errors

I’ve been developing a simple menu and using a ttf font with SpriteFont. This is with MonoGame 3.7.1708. I’m building it in Visual Studio 2019.

It’ll work for a while then stop. This is on a cheap Chinese Android. I just tried it on another model of Android (BLU) and it came up with the error. I loaded the Content.mgcb into the PipeLine, did a clean followed by a Rebuild then a rebuild in VS 2019 and ran it without debugging. That worked, as did running with debugging.

It seems to work for a while then something upsets it and it takes the clean/rebuild and rebuild to fix it. Any suggestions?

Hey, I’m having the same issue, except in my case it seems completely random when the content is able to load.

Going through the procedure of a clean followed by a Rebuild then a rebuild seems to have no effect.
I’m running my app through an activity in a xamarin forms app, the actual game itself is located in a monogame shared project.
I’ve tried running it as a standalone project for testing purposes and it seems to work in those cases.

Did you ever figure out a fix for this?

I believe I’ve found a fix for this.
You need to turn “Use Shared Runtime” off in:
Project > Properties > Android Options

Thanks. It certainly copies a lot more files when you untick that!.60 MB!

Hey, I’m having the same issue. I have not encountered it on previous projects, I have no idea why it happens now. Disabling shared runtime do seem to fix it, but as @DavidBolton mention building takes more time without it, so if anyone find another fix it would save me a lot of time.

I’ve found it can occur for a few reasons:

  1. Something changed in the Project and requires a complete PipeLine Rebuild and Clean… .
  2. Typo, I instead of i in a name.

I’ve also found that quite often a code change won’t trigger a deploy. It runs the previous code.

I’ve taken to doing quite a few changes in one go then doing a clean before a debug run to force a deploy.

Now for me it won’t even work when I disable shared runtime and even after a clean and rebuild. It’s just so random and frustrating… I agree that it seems to occur after some changes were made in the project.

When I run into this type of thing, I go on a /bin and /obj deleting spree. The tooling should regenerate both when you clean and rebuild, but I’ve found that at times it does not, and doing this works. Additionally be sure to delete these directories underneath the Content folders too.

Thanks, this works for me better than the clean and rebuild method which is inconsistent on my end too. But it’s still a temporary fix that allows to build only one time, the error will show up at the next build attempt.

Maybe it happens because the project contains several ddl files. That’s what different for me from other android MG projects.

To automatically “Clean” when clicking the build button you can add these lines to the prebuild event (Settings > Build Events):

del /F /Q $(ProjectDir)\bin
del /F /Q $(ProjectDir)\obj
del /F /Q $(ProjectDir)\Content\bin
del /F /Q $(ProjectDir)\Content\obj

It should save you two click when building if like me this issue is permanent.

1 Like