Error running Test:The parameter 'exePath' is invalid RRS feed

  • Question

  • I am developing an application with a data layer and writing tests for my business objects.

    The problem I'm experiencing is that I get the connection string from the configuration file like this:

    Configuration config = ConfigurationManager.OpenExeConfiguration("Application.exe");
    ConnectionStringsSection connectionStrings
    	= (ConnectionStringsSection)config.GetSection("connectionStrings");
    // Add the username and password to the connection string and save it
    string connectionString = String.Format("{0}user id={1};password={2}",
    	username, password);
    // Save the encrypted connection string to the settings for future use
    	= Encryption.EncryptData(connectionString);

    There is no problem when I run or debug the application, but when I run my tests I receive the error message "The parameter 'exePath' is invalid".

    Your help is really appreciated.

    PS: Running VS2008 on Vista Ultimate


    Monday, May 10, 2010 3:51 PM


  • The only solution I could find, for those interested is to define a symbol in my data later project (in my case I used MSTEST) and use preprocessors to call the different configuration files.

    I created an app.config for the Test project with the exact same contents as my applications project and changed this line as follows:

    // Changed this line
    Configuration config = ConfigurationManager.OpenExeConfiguration("Application.exe");
    // To this
    #if !MSTEST
    Configuration config = ConfigurationManager.OpenExeConfiguration("Application.exe");
    Configuration config = ConfigurationManager.OpenExeConfiguration("Application.Tests.dll");

    This way the tests work.

    Thank you,


    • Marked as answer by JFercan Tuesday, March 29, 2011 11:38 PM
    Monday, May 10, 2010 5:08 PM