After testing various graphics buffer dimensions and fullscreen mode I for some reason now receive the following error:
‘System.NullReferenceException: ‘Object reference not set to an instance of an object.’
which occurs as a result of the following code:
public virtual void LoadContent() { if (content == null) {content = new ContentManager(screenManager.Game.Services,“Content”);} }
This code itself is not the issue, just simply that ContentManager no longer seems to exist. Prior to this error occurring I did experience a crash when testing fullscreen mode. Could the crash have somehow corrupted the Monogame graphics code/files?
What needs to be done to re-establish the ContentManager?
Any assistance will be most appreciated, as I currently cannot run my game even with the same code that has worked fine until now.
Have you tried cleaning and rebuilding the project? usually something in debug can get trapped between builds and stays glued to a new build, cleaning the project usually fixes these “My code feels corrupted” experiences, we have all been there.
Thanks for your suggestion MrValentine, unfortunately cleaning and rebuilding brings no joy.
What I can’t understand is why at the point of the ContentManager variable ‘content’ being assigned an object instance, that it states it cannot be assigned a value as it is null. More perplexing is that this is the exact code that has run fault-free every other time.
As I can’t even run my game anymore it is bringing me great distress. What am I to do?
It seems an unrelated line of code I added to the Game class constructor was the culprit. Apparently, updating an array value here is cause for chaos. Who would have thought?