An Error Occurred Loading A Configuration File Exepath
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings an error occurred loading a configuration file the parameter 'exepath' is invalid and policies of this site About Us Learn more about Stack Overflow an error occurred loading a configuration file access to the path .tmp is denied the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation an error occurred loading a configuration file failed to start monitoring changes to web config Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
An Error Occurred Loading A Configuration File Failed To Start Monitoring Changes T
only takes a minute: Sign up ConfigurationManager.OpenExeConfiguration - loads the wrong file? up vote 25 down vote favorite 1 I have added multiple app.config (each with a differet name) files to a project, and set them to copy to the output directory on each build. I try and access the contents of each file using this: System.Configuration.Configuration o = ConfigurationManager.OpenExeConfiguration(@"app1.config"); an error occurred loading a configuration file failed to map the path '/' The code runs, but o.HasFile ends up False, and o.FilePath ends up "app1.config.config". If I change to code: System.Configuration.Configuration o = ConfigurationManager.OpenExeConfiguration(@"app1"); Then the code bombs with "An error occurred loading a configuration file: The parameter 'exePath' is invalid. Parameter name: exePath". If I copy/paste the config file (so I end up with app1.config and app1.config.config) then the code runs fine, however, I posit this is not a good solution. My question is thus: how can I use ConfigurationManager.OpenExeConfiguration to load a config file corretly? c# configurationmanager share|improve this question asked Jul 5 '09 at 11:55 user9659 3961617 add a comment| 4 Answers 4 active oldest votes up vote 32 down vote I can't remember where I found this solution but here is how I managed to load a specific exe configuration file: ExeConfigurationFileMap map = new ExeConfigurationFileMap { ExeConfigFilename = "EXECONFIG_PATH" }; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); share|improve this answer answered Sep 25 '12 at 16:21 user1697877 42143 1 That works! Crazy that it was that much work figuring out how to just read a lou
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and c# an error occurred loading a configuration file the parameter 'exepath' is invalid policies of this site About Us Learn more about Stack Overflow the
Openexeconfiguration Example
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Configurationmanager.openexeconfiguration Exepath
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/1083927/configurationmanager-openexeconfiguration-loads-the-wrong-file takes a minute: Sign up Getting error in loading Configuration file,Parameter is not valid up vote 0 down vote favorite 1 I have an installer class which is retrieving the parameters from the Visual Studio Setup project.Now on opening the exeConfiguration i am getting following error.. Error 1001:An error occurred loading a configuration file. The parameter 'exePath' is invalid. Parameter name:exepath-->The http://stackoverflow.com/questions/20697724/getting-error-in-loading-configuration-file-parameter-is-not-valid Parameter 'exePath' is invalid. Parameter name:exePath And here is my Installer.cs Code.. public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); string targetDirectory = Context.Parameters["targetdir"]; string param1 = Context.Parameters["Param1"]; string param2 = Context.Parameters["Param2"]; string param3 = Context.Parameters["Param3"]; string exePath = string.Format("{0}TechSoft CallBill.exe", targetDirectory); Configuration config = ConfigurationManager.OpenExeConfiguration(exePath); config.AppSettings.Settings["Param1"].Value = param1; config.AppSettings.Settings["Param2"].Value = param2; config.AppSettings.Settings["Param3"].Value = param3; config.Save(); } Please help me to sort out this error As i am not able to figure out. Any suggestion is heartily welcomed. Thanks in advance c# configuration installer string-formatting configurationmanager share|improve this question edited Dec 20 '13 at 7:02 asked Dec 20 '13 at 6:34 Adi 48941742 1 Are you trying to load the config belongs to a different project ? or it belongs to installer class project ? –Kurubaran Dec 20 '13 at 6:58 @AccessDenied Thank u very much sir.Config belongs to the installer class project.Here i am attaching the project classpath image. –Adi Dec 20 '13 at 7:01 @AccessDenied Please sir tell me where i am going wrong? –Adi Dec 20 '13 at 7:30 Check
digital channels at scale Software Quality Test Studio Release better quality software faster Individual Products DevTools Web UI for ASP.NET AJAX UI for ASP.NET MVC http://www.telerik.com/forums/override-app-config UI for ASP.NET Core UI for PHP UI for JSP UI http://sandblogaspnet.blogspot.com/2009/06/reading-from-configuration-file-in-net.html for Silverlight HTML5/JS Framework Kendo UI NativeScript Desktop UI for WPF UI for WinForms Mobile UI for NativeScript UI for Xamarin UI for UWP (Windows 10) UI for iOS UI for Android UI for Windows Universal UI for Windows Phone PRODUCTIVITY & QUALITY an error JustCode JustMock Testing Framework Debugging Fiddler JustDecompile JustTrace Reporting & Data Access Reporting Report Server Data Access DEPLOYMENT Modulus Mobile App Development Telerik Platform AppBuilder Analytics Backend Services Testing Test Studio Mobile Testing API Testing Digital Content & Experience Progress Sitefinity CMS Progress Sitefinity Digital Experience Cloud ENTERPRISE FREE TRIALS PRICING SUPPORT an error occurred & LEARNING ABOUT US YOUR ACCOUNT Search Your Account Telerik Platform Telerik Forums / Test Studio Forum / General Discussions / Override app.config Cancel The title field is required! Test Studio Resources Buy Try Feed for this thread 10 posts, 0 answers Govind 13 posts Member since: Aug 2014 Posted 26 Aug 2014 Link to this post Hi, I am using Test Studio Standalone, as per the override app.config guide, i cut and pasted the VB code. I added the references (System.Configuration), System.Reflection namespace already existed. I am getting a runtime error..... InnerException: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: The parameter 'exePath' is invalid. Parameter name: exePath ---> System.ArgumentException: The parameter 'exePath' is invalid. code: Public Sub readExcel_CodedStep3() 'Navigate to : 'http://www.google.com.au/' ActiveBrowser.NavigateTo("http://www.google.com.au/", true) Dim [me] As Assembly = Assembly.GetExecutingAssembly() Log.WriteLine([me].ManifestModule.Name) Log.WriteLine(Me.ExecutionContext.DeploymentDirectory) Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(System.IO.Path.Combine(Me.ExecutionContext.DeploymentDirectory, [me].ManifestModule.Name)) Assert.IsNotNull(config) Dim url As String = config.AppSettings.Settings("LoginPageUrl").Value 'Log.WriteLine(url) Dim name As String = config.AppSettings.Settings("LoginName").Value 'Log.WriteLine(name) Dim pw As String = config.AppSettings.Settings("Pass
a web application which had an exe added as a reference to the project. The exe had its own App.Config file where some setting related to the application was saved and these were read using the code below. Pretty straight forward code. private static string userName = ConfigurationSettings.AppSettings["UserName"].ToString(); private static string userEmail = ConfigurationSettings.AppSettings["UserEmail"].ToString(); In the above code we are trying to retrieve value from the AppSettings section of the App.Config file of the application using the ConfigurationSettings class' AppSettings property which is a namevalue collection object. The above approach is a deprecated method. Instead of the above approach, one can make use of the below code to retrieve the appsettings values. private static string userName = ConfigurationManager.AppSettings["UserName"].ToString(); private static string userEmail = ConfigurationManager.AppSettings["UserEmail"].ToString(); ConfigurationSettings API has become obsolete and has been replaced with the ConfigurationManager class to read the configuration setting of an applicatioin. To read the application settings or AppSettings of an application one can make use of ConfigurationManager.AppSettings. But my problem was not related to the API becoming obsolete. The system was throwing error when the system was trying to read the configuration. The errors are pasted below. The parameter 'exePath' is invalid. Parameter name: exePath An error occurred loading a configuration file: The parameter 'exePath' is invalid. Parameter name: exePath Object reference not set to an instance of an object. The reason why these errors were thrown is that while we were trying to read the keys from the configuration file the key were actually not present in the "AppSettings" section. As I said earlier the exe file was added as a reference in an ASP.NET web application and due to some reason when the exe code was accessed through the ASP.NET web application it was throwing error. The same exe application when executed independently was running without any e