Exit(); not allowed When referencing monogame windows DX

I have run the windows installer for Monogame 3.6 and told my project to reference monogame for windows desktop (directX) and as you can see I can’t call Exit();

Also on windows 10 client window resizing no longer calls the Window.ClientSizeChanged event which is a little irritating.

Imgur

Update: Also verified that other team member references the exact same DLL and gets different results. Exit() works on his end.

I find the work-around is referencing by file path the DLL inside the monogame directory under windows sub folder. However they should be the same DLL, so what happened?

It’s kind of a pain referencing by local file path.

I’ve encountered this problem before after uninstalling and reinstalling MonoGame, though not recently. I think it has something to do with project types, and the project for some reason thinking it’s not a desktop DirectX project.

Try creating a new DirectX project, and check to make sure Exit() is allowed in that new project. If nothing else, you could copy over all of the code files and content into a new DirectX project and work with that.

Exit() should only be marked obsolete for iOS and Windows Phone 8. I just double checked the source code and the Obsolete attribute is not included for any other platform.

@Allogonist Are you 100% sure you’re referencing the exact same assembly? MG uses preprocessor directives to mark Exit() as obsolete for some platforms but not others, so whether exit is marked as obsolete or not is compiled into the assembly. It seems impossible that referencing the same assembly in another way can make a difference.

So, I have actually resolved this issue, it seems to have been either an issue with the monogame 3.6 installer or with Visual studio.

When selecting from the reference manager “MonoGame for Windows Desktop (DirectX)” under extensions targeting .net framework 4.5 I got the Exit() error flagged in my code. That is even after adding a “WINDOWS” conditional compilation directive.

The solution was to say screw the reference manager and reference the dll by direct file path. I Referenced the dll in C:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows

Note that this SHOULD be the exact same assembly as far as I understand, yet referencing the file by this path instead of from the assembly cache in visual studio produced different results in my code.

¯\(º_o)/¯

You can see in my original screen shot exactly which assembly I am referencing as well as the error I got when using that reference.