Friday, 1 October 2010

This application has failed to start because the application configuration is incorrect.


“Reinstalling the application may fix this problem.”

Yeah, right!

Here’s the scenario… you’ve written a simple console app.  It’s working fine on your test VM, which has the exact same version of Windows (e.g. Server 2003) as the customer’s test server.  You deploy it, try to run it, and you get the following cryptic message box (identifying information obfuscated here):


WTF?  You figure since it’s the same app, running under the same OS, and all you did was copy it, it must be an environmental issue, right?  But the customer verifies the .Net framework is properly installed; you even try copying the app from the problem machine to another machine in their environment; same issue; now you’re thinking maybe it’s a permissions thing, or something similar that’s preventing your app from running in their environment.

You Google it (or Bing it, or whatever it is you do ;-), and, you get a million hits of hog slop, none of which helps you.

You want to find out more so you go to “Computer Management” and check the System Event Log, and lo and behold, an event was logged related to what just happened:


You look at the event, read something about a “Manifest Parse Error,” and think, hang on, this is a simple console app, it doesn’t have a manifest.  WTF (x 2)?


You post something on a Microsoft forum and you receive the following advice:


I recommend you use a tool named Cordbg.exe, which helps tools vendors and application developers find and fix bugs in programs that target the .NET Framework common language runtime. This tool uses the runtime Debug API to provide debugging services.

Fore how to use the tool to debug:

If you still can't solve it with the tool, could you create a dump file about the application and send to me, here is how to get dump file: 

end quote.

You spin your wheels on that for awhile, thinking, gee, this is a lot to have to deal with just to figure out why I’m getting this cryptic error.  Finally you start to think, hang on.  Let’s take a step back.  You think, what’s different between my dev machine and the customer’s environment?  And what’s up with this bogus Manifest Parse error?  Finally the light bulb lights.

Astute readers will have already figured this out.  If it was a snake it would’ve bit me, he says, smacking himself in the forehead.

What’s different?  What’s different is the config file that you deployed to their environment, which you then edited in their environment in Notepad, because they didn’t have Visual Studio in their environment, and you trashed it by entering some left or right bracket, thus corrupting your XML.  You didn’t know you did that, because unlike Visual Studio, Notepad doesn’t show you any nice red squiggly lines underneath your bad XML.

So you go grab the config file:


You copy its contents back into Visual Studio in your dev environment, and lo and behold, you see some red squiggly lines:


You correct the problem, copy the good XML back to the customer’s environment, and, whoopee!  Your app runs again, and all is well with the world.  A lengthy trial is held to determine whether you’re an idiot, or simply a human being who sometimes makes mistakes.  Your fingers are crossed; you may be let off the hook.

In my case the jury is still out!  ;-)

Bottom line:  if you get the error “the application has failed to start because the application configuration is incorrect,” check your app.config file (i.e. “yourApp.exe.config” after it’s been built) for bad XML, particularly the possibility of bad left and/or right angle brackets.

dB (doing my part to document MS error messages)

No comments:

Post a Comment