[FIXED] After publishing in 3.6, The installer doesn't run and debugging it throws a new error

Hi
I’m new to the process of git repositories and bug reporting so I’m sorry if I’ve gotten anything wrong here.

I just moved my code over to the latest Monogame version (3.6.0.1352) from 3.5 and after publishing, neither the installer or ClickOnce will run with the error message “Cannot continue. The application is improperly formatted. Contact the application vendor for assistance.” The project will run without any issues when launched from the code editor.

The same thing happens when building from source and trying different target platforms, even on a completely new template project.

I’m using VS2015 with Windows 7 64bit

Some of the projects when run from the IDE give an error “An unhandled exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll” when run. I’m not sure if this has anything to do with the published versions not running because a project without that error still doesn’t run when published.

I’d really appreciate any help, thanks very much.

EDIT:
I’m more clear on the order of these errors now though, if I create a new project from the template, it will run in editor fine but the published version will give me the format error, then if I try to run it in VS again it will throw “An unhandled exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll” and it can’t be run again. So new, clean projects work until they’re published and then stop working.

It’s a Monogame Cross Platform Desktop Project.

Have you looked in the logs if this is not due to a cinflict between monogame’s dll?
Also check the “published” /“application” folder on the deploy depot if thet contain the 3.5 or 3.6

Hey Alkher, thanks for replying.

Sorry but I’m not really sure how to find the log files (I’m new to this stuff) is it the same as the info in the output window that appears when you publish or build the project? Because nothing in there seems wrong.

I uninstalled Monogame completely and reinstalled the newest version before the error, so should there be any issue with version conflicts?

I’ve checked the published version, it has the latest monogame.Framework.dll in the folder with the application files and is referenced in the manifest, so it’s the same version it’s meant to compile with.

I’m more clear on the order of these errors now though, if I create a new project from the template, it will run in editor fine but the published version will give me the error I was describing earlier and then if I try to run it in VS again it will throw “An unhandled exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll” and it can’t be run again. So new, clean projects work until they’re published and then stop working.

Well I don’t use clickonce anymore, because of this:
When I updated the mysql connector, deploying on my computer was working. Installation of the app too.
But when the users were trying to install, it threw an exception. The dll was copied to the install dir, but was not registered in the GAC.
I’ve spent many hours to circumvent this problem, and ended with another solution.

Concerning your problem, in VisualStudio, go to “debug” -> “exceptions…”, and check the system.argumentnullexception.
Then try again, this time it “should fail where it fails”

That sounds really frustrating, I usually have no idea how to deal with framework errors like that.
The deploy files have always annoyed me though, I usually don’t use the .deploy extension, it’d be nice to be able to build and distribute as an exe but I hear that’s unreliable.

Okay, just tried that, it just says the “source not available” and doesn’t break into any code.

Hum… it seems to be related to a wrong reference to a dll.
After doing a publish action, and the app failing, have you tried to force a build with “rebuild” or did you only “build” it ?
Sometimes rebuilds forces files to be refreshed while build/debug keeps some files…

If you want a setup (a basic one), you can use a “Setup and deployment project”, it does not handles updates, but it creates a Windows Installer with .exe, shortcuts too, etc.
Or InnoSetup if you have some spare time to learn it.

Okay, I tried to rebuild it and it said it couldn’t copy the .exe (the vshost was still running) so after shutting that down I tried the rebuild and nothing changed, still gives all the same errors when debugging (“An unhandled exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll”).

To summarise:
1. On Windows 7, In VS2015, I create a new, blank “Monogame Cross Platform Desktop Project” using the latest Monogame development version 3.6.0.1365 (I tried a newer version since the first post and am still getting this error).

2. I run the project and everything builds fine showing the classic cornflower blue background.

3. I try to publish the project to the “publish/” folder (no matter what location, the error still persists).

4. I try to run the resulting installers/ClickOnce applications try to load but produce the message “Cannot continue. The application is improperly formatted. Contact the application vendor for assistance.”

5. I then go back into VS2015 and try to run/debug the project (like I would in step 2) but now the program crashes before running any code citing the error:

“An unhandled exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll
Additional information: Value cannot be null.”

The error takes Visual Studio to the “Source not available” page so I can’t tell what code is causing the issue.

6. The program new program now can’t be run or debugged at all since every time it returns the same error.

I’ve tried it in VS 2015 and VS 2013
I’ve tried installing the same Monogame & Visual studio on another computer with Windows 10 and the error is identical.
I’ve tried uninstalling the original Monogame first and uninstalling OpenAL
I’ve tried going back to version 3.5.1.1679 and everything works again except for some of the issues I’m trying to get rid of by upgrading to 3.6
I’ve tried placing a breakpoint on entry to the “main” function and the breakpoint is never hit.

I hate to keep pushing this thread up but I still badly need help with this issue.

Is there some step I’ve missed in installing a development version of Monogame?
Has anyone else had a similar issue before?

Again, I’d really appreciate any help you could give.

I will try to publish an app to see what happens.
Did you set ‘copy always’ on the properties of the reference to monogame? (by default it should be copy always)
It seems to be related to some template or something if 3.5 publishes and 3.6 prevents a normal publish

Thanks again Alkher

On another new project I tried changing the “MonoGame.Framework” in the references folder to “copy local = true” but that didn’t help.
I then changed the “libopenal.1.dylib,” “libSDL2-2.0.0.dylib,” and the “Monogame.framework.dll.config” library to copy always along with all the dll references in the x86 and x64 folders, again in a new project.

Here is what the solution explorer looks like, does this match yours?

I agree, I think it’s a template issue since 3.5 worked fine, but it’s really strange to me that I’ve run into this problem on two separate computers and that I can’t find anybody else with the same issue.

Okay, I figured it out!

I had to have the latest .Net version installed. I was on 4.6.1 and needed 4.6.2.

Thanks a ton for all the help, I really appreciate it :slight_smile:

That didn’t work for me. What did work was unchecking the following options that publish seems to enable after you try and publish.

Under the project’s properties uncheck:

  • Signing -> Sign the ClickOnce manifests
  • Signing -> Sign the assembly
  • Security -> Enable ClickOnce security settings

After doing this your settings are back to what they’d be if you created a new Monogame Windows Desktop Project.

Hope this helps someone else, I spent to long figuring this one out.

1 Like

Both of the solution given here dont work, anyone knows how to solve it ?

EDIT: i just installed .NET 4.6.2 and none of the checkbox mentioned by supaevensteven are check

Onbody else have the same problem ?

Thanks supaevensteven this worked like a charm