app-config

How to get admin privileges for editing app.config in C#?

柔情痞子 提交于 2019-12-04 02:06:26
问题 I've got a program which uses app.config for storing some preferences. The problem is that if the program is installed in C:\program files\<project name> then the changing of preferences is not possible due to the fact that all files in program files\<project name> are available only to administrator. My code: public static bool EditKeyPair(string key, string value) { bool success = true; // Open App.Config of executable System.Configuration.Configuration config = ConfigurationManager

Refreshing service references updates the app.config

旧时模样 提交于 2019-12-04 01:46:50
问题 Every time I make changes to my WS and update the reference in Visual Studio, VS overwrites my app.config with additional unnecessary information. So when I start my client afterwards, I get this error: An error was discovered processing the header The changes that the code generator made was to remove this line from every binding (note I'm using customBinding/httpsTransport): <security authenticationMode="UserNameOverTransport" includeTimestamp="false"> <secureConversationBootstrap/> <

Plugin to use its own app.config

妖精的绣舞 提交于 2019-12-04 00:33:35
I finally managed to build a working solution of a plugin architecture with help of some guys over here, but now a new problem arises. My hosting application uses it's app.config file for some defaults for the executing assembly (which is a Windows Service). Each plugin should be able to load it's own settings from a separate plugin settings file because the host shouldn't be made aware of the plugin settings. In the plugin project I added an app.config file as well (with some settings and a connection string) so that I can instantiate the Properties.Settings class and use it's properties in

Actually read AppSettings in ConfigureServices phase in ASP.NET Core

核能气质少年 提交于 2019-12-03 23:27:15
问题 I need to setup a few dependencies (services) in the ConfigureServices method in an ASP.NET Core 1.0 web application. The issue is that based on the new JSON configuration I need to setup a service or another. I can't seem to actually read the settings in the ConfigureServices phase of the app lifetime: public void ConfigureServices(IServiceCollection services) { var section = Configuration.GetSection("MySettings"); // this does not actually hold the settings services.Configure

ConnectionStrings in app.config. What about security?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 21:04:48
Is it really a Good Thing to put connection strings with passwords in the app.config file? It seems to me that the app.config is not encrypted in any way and the password information can be easily read. I have an app which accesses a database for which the intended end-user have no authentication. A group user/password is used. The application only starts if the current windows user is in an Active Directory group. So, once in the app, the user is allowed to connect to the DB using the group user. What would be the correct way to handle such connection strings? Hide them in the source code?

.NET Configuration Section Designer - Where is my collection?

会有一股神秘感。 提交于 2019-12-03 20:58:47
I am using the Configuration Section Designer for .NET to build a simple ConfigurationElementCollection . It appears that everything builds just fine and the code is automatically generated since the sub-elements are visible with Intellisense. Unfortunately, even though I have added elements to the collection in the configuration section, they do not exist at run-time; it shows the collection's Length property to be 0 - i.e. the collection is empty even though, as you can see in my example XML, I have clearly put them there: Example configuration <logParserSettings xmlns="LogParser">

Loading Properties.Settings from a different file at runtime

感情迁移 提交于 2019-12-03 20:10:58
问题 Is there any way to load settings from a different file other than the default App.config file at runtime? I'd like to do this after the default config file is loaded. I use the Settings.Settings GUI in Visual Studio to create my App.config file for me. The config file ends up looking like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture

Is ConfigurationManage -> section.SectionInformation.ProtectSection() machine dependent?

让人想犯罪 __ 提交于 2019-12-03 20:07:26
问题 in the code Configuration config = ConfigurationManager.OpenExeConfiguration (Application.ExecutablePath); ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; if (!section.SectionInformation.IsProtected) { section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); } I´m getting some trouble when I move the application to another machine. is the section.SectionInformation.ProtectSection call machine dependent, meaning, I

Load configuration file from stream instead of file

那年仲夏 提交于 2019-12-03 16:54:57
I use OpenMappedExeConfiguration with ExeConfigurationFileMap to load configuration files. Their overloads suggest that they only work with filenames. Is there a way to load a configuration file from a stream? Background: I want to load configuration files that are stored as embedded resources. There is no file representation! No. The problem is that this class itself do not read the configuration. The file path itself is eventually used by the Configuration class to load the configuration, and this class actually wants a physical path. I think the only solution is to store the file to a

How do I create a Solution Wide Connection String

拜拜、爱过 提交于 2019-12-03 16:12:24
Does anyone know if it is possible to create a single connection string that will be accessible to all the projects in a solution (we have about 6). I can create a text file with this information, but we need design time support as well, and it is not practical to have a connection string in every App.Config and Web.config file in the solution. We basically want a Single connection string that is easy to change should the location of the db change, that will also be used by the IDE for design time support mafu Not sure, can't you just put a new config file to the solution items and include and