Side by Side Error

Summary

In this blog post I’m going to demonstrate how to generate an error that is difficult to find.

The Error

The error message that I’m going to show can be caused by a lot of different things.  The cause of this error will be the use of an “&” symbol inside the app.config file.  The error message you get will be:

The application has failed to start because its side-by-side configuration is incorrect.  Please see the application event log or use the command-line sxstrace.exe tool for more detail.

If you get this error, you’ll need to go to the control panel and open up the event viewer.  Then look under the applications section and look for a side-by-side error message.  This message will probably point you in the right direction.  Now I’m going to show how to generate this error with a few lines of code.  First, I’m going to create a console program in C# with Visual Studio 2015:

using System;
using System.Configuration;

namespace SideBySideBlogPost
{
    class Program
    {
        static void Main(string[] args)
        {
            string temp = ConfigurationManager.AppSettings[“test“];

            Console.WriteLine(“test output“);
            Console.ReadKey();
        }
    }
}

Then I’m going to create an app.config file and add the following inside the <configuration> section:

<appSettings>
    <add key=”testvalue=”test output & more testing“/>
</appSettings>

If you are using Visual Studio 2015, you’ll notice that you can’t compile the program because the “&” symbol is not allowed.  So I removed the symbol, compiled the program and edited it in the resulting app.config file in the bin/debug directory.  Then ran the program.  Here’s what the event viewer looks like:

 

 

Leave a Reply