app-config

MSTest and app.config issue

匆匆过客 提交于 2019-11-28 21:06:28
I am stuck trying to automate unit tests runs with MSTest and deployment of app.config. I read multiple posts and blogs, tried multiple things and yet still app.config doesn't seem to be picked up during MSTest execution. Having a dll that contains all my unit tests built with msbuild, here is what I've tried... Attempt 1 Copied app.config to the same location with MyTests.dll as MyTests.dll.config (on one of the msdn forums it was said it'd be picked up automagically) Added [DeploymentItem("MyTests.dll.config")] attribute to each test Ran MSTest.exe /noisolation /testcontainer:d:\MyTestTests

Why my changes of AppSettings in App.config is not taken into account in run-time? (Console Application)

梦想与她 提交于 2019-11-28 20:49:30
I have a console application which has its own App.config. I need to change some values in section time to time. My problem is, when I execute the exe within the bin/debug folder it gets the relevant appsettings correctly. But when I edit and change values of some key/value pairs and RE-RUN the exe, it still reads the original values. (By RE-RUN I mean running the application on the command promt by calling MyTool.exe) I tried to call ConfigurationManager.RefreshSection("appSettings"); in the begining of my Main method. But did not help. Can you please advise? Thanks But when I edit and change

When is an app.config created, when an app.exe.config and what is the difference

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 20:24:27
We have created a WinForms application and store some configurations via the ConfigurationManager class. In order to store the information I use Configuration pConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); pConfig.AppSettings.Settings.Add("updates", szUpdatesURL); pConfig.Save(ConfigurationSaveMode.Modified); The problem here is that in some occasions the application creates an "appname".config file and in other occasions an "appname".exe.config. Here I must note that a configuration file is not shipped by default since it is not always required. The

Is reading app.config expensive?

余生颓废 提交于 2019-11-28 20:19:58
No question I am yet to be hit by any read speed bottleneck. I am asking to know; if reading app.config frequently is a bad programming choice. I have known of database operations getting expensive. In my case I am not reading my own application's app.config, but of another project's , like this: private string GetAppConfigValue(string key) { ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = GetConfigFilePath(); Configuration appConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); return appConfig.AppSettings

Is ConfigurationManager.AppSettings available in .NET Core 2.0?

安稳与你 提交于 2019-11-28 18:30:26
I've got a method that reads settings from my config file like this: var value = ConfigurationManager.AppSettings[key]; It compiles fine when targeting .NET Standard 2.0 only. Now I need multiple targets, so I updated my project file with: <TargetFrameworks>netcoreapp2.0;net461;netstandard2.0</TargetFrameworks> But now, the compilation fails for netcoreapp2.0 with the following error message: Error CS0103 The name 'ConfigurationManager' does not exist in the current context (netcoreapp2.0) Separately, I created a new .NET Core 2.0 console application (only targeting .NET Core 2.0 this time),

sub appsettings in the appsetting node c#

浪尽此生 提交于 2019-11-28 17:25:59
问题 I am using the app.config file that is created with a console application and I can read the val1 of the key1 using the ConfigurationSettings.AppSettings["key1"].ToString() <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> </startup> <appSettings> <add key="key1" value="val1" /> <add key="key2" value="val2" /> </appSettings> </configuration> but I have too many keys and values that I want to make them categorized. I found something that is

How do I get intellisense in app.config for a custom section?

不问归期 提交于 2019-11-28 16:47:21
问题 We have a custom section in my app.config file related to our IoC container class. How can I get intellisense when editing the config file for this section, as well as getting rid of the compiler messages informing me of the missing schema. I found this question here: app.config configSections custom settings can not find schema information, but I don't understand if it applies to my problem or not, and how to use the answer there if it does. I also found this page How to get Intellisense for

Enabling Intellisense for Custom Sections in .config Files

末鹿安然 提交于 2019-11-28 16:21:29
When editing .NET config files (app.config, web.config, etc) in Visual Studio, I get Visual Studio's intellisense to guide me when choosing my application's settings. If I add a custom configuration section, how can I enable intellisense for my custom settings? I'm sure there must be an easy answer to this, but a cursory Google search didn't give me any help. Thanks! Michael Stum If you do not want to modify your Visual Studio files or copy anything into the Visual Studio folder, you can add the .xsd file to your project, open your .config file and select Schemas in the Properties window

How should I edit an Entity Framework connection string?

痴心易碎 提交于 2019-11-28 16:16:22
I recently had to edit my app.config file to change the connection string for an Entity Framework data model ( .edmx file). But I'd like to know: Is there a way to edit the EF connection string using the designer? The original connection string is auto-generated by the Entity Data Model wizard. The connection string then cannot be changed - it remains disabled in the properties window of the .edmx designer. I like to avoid editing XML by hand if I can (in app.config), so I was wondering if there is a way to get back into the original wizard screen to make connection string changes and let the

Settings.settings vs. app.config in .NET desktop app [duplicate]

你离开我真会死。 提交于 2019-11-28 15:37:50
Possible Duplicate: What is the difference between app.config file and XYZ.settings file? I am quite confused by the apparent redundancy of these two mechanisms in Visual Studio to store and manage desktop application settings: You can use the XML app.config file, adding items to the <appSettings> section. These can be retrieved from code using the ConfigurationManager class. Alternatively, you can use the Settings.settings file to add individual settings through an editor. Visual Studio will generate a Settings class for type-safe retrieval of settings at run-time. These two mechanisms seem