configurationmanager

How to Write to a User.Config file through ConfigurationManager?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 18:54:48
问题 I'm trying to persist user settings to a configuration file using ConfigurationManager. I want to scope these settings to the user only, because application changes can't be saved on Vista/Win 7 without admin privileges. This seems to get me the user's configuration, which appears to be saved here in Win 7 ([Drive]:\Users\[Username]\AppData\Local\[ApplicationName]\[AssemblyName][hash]\[Version\) Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel

Java configuration framework [closed]

冷暖自知 提交于 2019-12-17 17:25:31
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm in the process of weeding out all hardcoded values in a Java library and was wondering what framework would be the best (in terms

Danger of using reflection to add Connection Strings to ConfigurationManager.ConnectionString

為{幸葍}努か 提交于 2019-12-13 02:17:38
问题 I have seen several post detailing how to get around the ReadOnly barrier in adding connection strings to ConfigurationManager.ConnectionStrings. See an example of one such post below. Along of each of these examples comes a dire, yet vague warning that the technique employed is "dangerous". What is the danger? Dim cssc As ConnectionStringSettingsCollection = WebConfigurationManager.ConnectionStrings Dim t As Type = cssc.GetType().BaseType ' System.Configuration.ConfigurationElementCollection

ConfigurationManager.save() fails

倾然丶 夕夏残阳落幕 提交于 2019-12-12 11:35:05
问题 I am writing a C# application(no WinForms). Having read several threads about ConfigurationManager i have ended with the following code: public static string GetValue(string key) { Configuration configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var settings = configFile.AppSettings.Settings; if (settings[key] == null) throw new ArgumentException("Requested unknown key from Application Configuration("+configFile.FilePath+")",key); System.Console.Out.WriteLine

Visual Studio New Debug Configuration

我的梦境 提交于 2019-12-12 04:44:44
问题 I am trying to configure Visual Studio 2010, to add a Debug configuration. Configuration Manager->either by starting in the active solution configuration:, or Project, added New, created a New configuration, copied from Debug... (if solution, either created new configuration, or just used Debug and added new project configuration)... http://msdn.microsoft.com/en-us/library/kwybya3w.aspx Build -> errors that suggest a mix of Debug and Release: defaultlib 'LIBCMT' conflicts with use of other

How can I get attribute from subsection webconfig C#?

时光毁灭记忆、已成空白 提交于 2019-12-12 01:47:50
问题 I try to get all attibutes from one subsection, but section have many subsection and the aplication didn't recognize, how can I do? this is my webconfig: <configSections> <section name="Seccion" type="ManejoConfiguracion.SeccionConfig,ManejoConfiguracion"/> </configSections> <Seccion> <BD> <add key="name" value="dbKey" /> <add key="user" value="userBD" /> <add key="pass" value="123BD" /> </BD> <ReportingService> <add key="name" value="Reporting" /> <add key="user" value="userReport" /> <

ASP.Net MVC 3 Configuration

大憨熊 提交于 2019-12-11 10:39:11
问题 i want to ask about ASP.Net Configuration. i have a project that use ASP.Net MVC3. and i use membership in my project. in my database server, there's 2 database for my project. aspnetdb, contains aspnet_membership, aspnet_user, aspnet_roles, etc (i use asp.net Configuration) mydatabase, its for my project database. now my boss told me that he want to host my project in public and told me to use only one database. so i have to move aspnetdb to mydatabase. how can i do it without making new

.Net Standard 2.0 ConfigurationManager Doesn't Read Connection Strings

笑着哭i 提交于 2019-12-11 05:06:55
问题 I have a .Net Standard 2.0 Library. I've references System.Configuration.ConfigurationManager via NuGet and I've added an App.config file with two connection strings. When I break on the following line, I notice that ConnectionStrings only contains a single connection string which is neither of the connection strings I have in my App.Config (shown below). var foo = ConfigurationManager.ConnectionStrings["cs1"].ConnectionString; The single connection string which does appear in

Configuration.GetSection(“basicHttpBinding”) not reading that section from app.config file

那年仲夏 提交于 2019-12-11 04:41:49
问题 I have the following property: protected BasicHttpBinding Binding { get { var config = ConfigurationManager.GetSection("basicHttpBinding") as ServiceModelSectionGroup; foreach (ChannelEndpointElement bindings in config.Bindings.BasicHttpBinding.Bindings) { string binding = bindings.Binding; if (binding != null) { return new BasicHttpBinding(binding); } } return null; } } When I debug it, it fails with a null exception: Object reference not set to an instance of an object at this line: foreach

System.NullReferenceException with windows service of DB connection string

核能气质少年 提交于 2019-12-11 02:38:48
问题 I am writting a windows service, and I catch an exception using try: try { connStr = System.Configuration.ConfigurationManager.AppSettings["connStr"].ToString(); } catch (Exception ex) { logger.Error("get the connection string failed,detail:" + ex.ToString()); } The output is: get the connection string failed,detail:System.NullReferenceException: not set an instance with a object reference. It can't get the connection string correctly. And this is my configuration file(app.config) :