appsettings

How can I read/write app.config settings at runtime without using user settings?

五迷三道 提交于 2019-12-17 06:37:04
问题 I'm looking for a way to store application or machine level settings that can be written to at runtime using Application Settings. User settings allow read/write but application settings do not. I have been using user settings for saving settings like this at runtime but this has really proven to be impractical for the following reasons: All users of the machine need to share settings. In support calls (especially in crisis situations) it is difficult to explain to users/employees where to

Bind to a value defined in the Settings

主宰稳场 提交于 2019-12-17 01:58:06
问题 In WPF, Can I use binding with values defined in Settings? If this is possible, please provide a sample. 回答1: First, you need to add a custom XML namespace that will design the namespace where the settings are defined: xmlns:properties="clr-namespace:TestSettings.Properties" Then, in your XAML file, access the default settings instance using the following syntax: {x:Static properties:Settings.Default} So here is the final result code: <ListBox x:Name="lb" ItemsSource="{Binding Source={x

Reading settings from app.config or web.config in .NET

只愿长相守 提交于 2019-12-16 22:23:07
问题 I'm working on a C# class library that needs to be able to read settings from the web.config or app.config file (depending on whether the DLL is referenced from an ASP.NET web application or a Windows Forms application). I've found that ConfigurationSettings.AppSettings.Get("MySetting") works, but that code has been marked as deprecated by Microsoft. I've read that I should be using: ConfigurationManager.AppSettings["MySetting"] However, the System.Configuration.ConfigurationManager class

Modifying connection string with variables

╄→尐↘猪︶ㄣ 提交于 2019-12-12 12:28:12
问题 so my goal is to have a "settings form" which allows users to edit the connection string (by changing the database name / server location. The reason for this is that it it needs to be able to changed when the server locations changes shortly by someone who may not have any C# experience (Front-End GUI). I've created the connection strings in app.config but cannot find a way to assign variables inside the conn string that can be changed? I've created some application wide settings using the

How do I access a NameValueCollection (like Request.Form or ConfigurationManager.AppSettings) as a dynamic object?

为君一笑 提交于 2019-12-12 06:09:27
问题 Is there a way to access a NameValueCollection (like Request.Form or ConfigurationManager.AppSettings) as a dynamic object? I'd like to be able to do something like this: var settings = ConfigurationManager.AppSettings.AsDynamic(); var name = settings.Name; // ConfigurationManger.AppSettings["Name"] // but also settings.Name = "Jones"; // modify the original collection // and var form = Request.Form.AsDynamic(); var email = form.Email; // Request.Form["Email"] (this question is based on

Sharing AppSettings and ConnectionStrings between a console and a web app

ぃ、小莉子 提交于 2019-12-11 17:33:02
问题 I have a multi-tiered ASP.Net MVC 3 application in which different layers need to share some settings, and I am wondering how to best achieve this. For now, all my AppSettings are in the Web.config file, but I just added a new project to my solution to create a console application that will be called every night buy the Windows Task Scheduler to perform routine maintenance tasks. This console application will be using the same database, repository layer, service layer, etc. as the web

Getting ConnectionStrings config settings from appsettings.json

家住魔仙堡 提交于 2019-12-11 15:49:42
问题 In my repository class, I have my Config object and looks like my connection string is under: Config > Providers > Microsoft.Configuration.Json.JsonConfigurationProvider > Data > ConnectionStrings.myConnectionString This is what my appsettings.json looks like: { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "ConnectionStrings": { "myConnectionString": details..." } } I'm trying to read myConnectionString as follows which is not working: var cs = _config

Weird error message when running my application

风流意气都作罢 提交于 2019-12-11 12:14:49
问题 Guys I created a console application in Visual Studio 2010. It targets the .NET framework 2.0. When I run the application is Visual Studio, it works perfect. I then exited Visual Studio and copied the executable to my C:\Windows\System32 directory. When I open a command prompt window and try to execute my program, it comes up with a standard Windows message box with an error that says "Unable to find a version of the runtime to run this application". I know I got the .NET framework installed.

Some strings are not translated when changing system language without restarting app

强颜欢笑 提交于 2019-12-11 11:17:11
问题 I'm having a problem where if I open my android app and then go into the system settings to change the language and then open the app again, some strings in the app won't be translated unless the app is force quit and relaunched. Any idea why this happens? I don't have android:configChanges set to "locale" anywhere in my AndroidManifest , so doesn't this mean all activities should be restarted on their own? 回答1: I also had this issue.I used the code below which was posted in some

Reading and Writing keys to appsettings in WebConfigEditor

我与影子孤独终老i 提交于 2019-12-11 07:04:11
问题 My project contains web.config file and an external appSettings file. I am making a WebConfig Editor that has options to Read AppSettings key from web.config and external appSetting file to display them on webPage. Also, I am allowing user to delete any key by clicking on Remove button. Moreover, user can also update any key's value by clicking on update button.Or he can also insert new key by clicking on Add New Key button. The key issue I am facing is that whenfever I try to add a new key ,