configurationmanager

Does SQL Server CLR Integration support configuration files?

一曲冷凌霜 提交于 2019-11-28 00:40:38
问题 I use SQL Server CLR Integration to create an ASSEMBLY. Load Command: CREATE ASSEMBLY TcpClr FROM 'G:\TcpClrTest.dll' WITH PERMISSION_SET = UNSAFE Without App.Config The dll code contains : string ip=ConfigurationManager.AppSettings["connection"].ToString(); Also the App.config contains : <appSettings> <add key="connection" value="127.0.0.1"/> </appSettings> But when I execute the PROCEDURE,the SQL Server shows an error System.NullReferenceException Does SQL Server CLR Integration support App

Is there a way to get a System.Configuration.Configuration instance based on arbitrary xml?

陌路散爱 提交于 2019-11-27 22:55:36
I'm trying to unit test a custom ConfigurationSection I've written, and I'd like to load some arbitrary configuration XML into a System.Configuration.Configuration for each test (rather than put the test configuration xml in the Tests.dll.config file. That is, I'd like to do something like this: Configuration testConfig = new Configuration("<?xml version=\"1.0\"?><configuration>...</configuration>"); MyCustomConfigSection section = testConfig.GetSection("mycustomconfigsection"); Assert.That(section != null); However, it looks like ConfigurationManager will only give you Configuration instances

How to read values from multiple Configuration file in c# within a single project?

筅森魡賤 提交于 2019-11-27 15:18:42
问题 Here in my project I have two application configuration files called app.config and accessLevel.config . Now using the OpenExeConfiguration I was able to access the app.config.exe file but not the accessLevel.config . Please help on this. The main reason I have 2 config files is to show the difference and make the code simple. I need to read the values from the accessLevel.config in my C# code. Tried the below code but no use: System.Configuration.Configuration config = ConfigurationManager

Can someone provide a quick App.config/Web.config tutorial?

ぐ巨炮叔叔 提交于 2019-11-27 15:08:38
问题 I've used these two configuration files many times before, but I've never taken the time to fully understand how they really work. As most people do, I understand the basics in how to call WebConfigurationManager.AppSettings["key"] to get config values. Here are some questions I came up with: What happens when you reference a configuration value within a class library, and the library is part of a bigger solution? Does the app.config need to be copied to the output directory in order for the

How to load application settings to NHibernate.Cfg.Configuration object?

岁酱吖の 提交于 2019-11-27 14:58:34
问题 How to load application settings to NHibernate.Cfg.Configuration object by using System.Configuration.ConfigurationManager from App.config? 回答1: app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="Northwind" connectionString= "Data Source=(local);Initial Catalog=Northwind;Trusted_Connection=True;> </connectionStrings> </configuration> C# code: string connectionString = System.Configuration.ConfigurationManager .ConnectionStrings["Northwind"]

Open other program's configuration files

怎甘沉沦 提交于 2019-11-27 14:01:02
问题 I have a program A , it also have an app.config file where I have added some keys like server address, username and password for connecting to a server. It is a console application. Now I want to make a UI which I have done. In that UI I want to modify the content of app.config of program A . How do I do that? Here is what I tried, I copied the UI (basically an .exe) to program A's directory, where the app.config also resides. Then in the UI, I use the ConfigurationManager class's

Can ConfigurationManager retain XML comments on Save()?

允我心安 提交于 2019-11-27 13:46:08
问题 I've written a small utility that allows me to change a simple AppSetting for another application's App.config file, and then save the changes: //save a backup copy first. var cfg = ConfigurationManager.OpenExeConfiguration(pathToExeFile); cfg.SaveAs(cfg.FilePath + "." + DateTime.Now.ToFileTime() + ".bak"); //reopen the original config again and update it. cfg = ConfigurationManager.OpenExeConfiguration(pathToExeFile); var setting = cfg.AppSettings.Settings[keyName]; setting.Value = newValue;

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

有些话、适合烂在心里 提交于 2019-11-27 13:13:07
问题 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

How to find path of active app.config file?

﹥>﹥吖頭↗ 提交于 2019-11-27 10:12:13
I'm trying to finish this exception handler: if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null) { string pathOfActiveConfigFile = ...? throw new ConfigurationErrorsException( "You either forgot to set the connection string, or " + "you're using a unit test framework that looks for "+ "the config file in strange places, update this file : " + pathOfActiveConfigFile); } This problem seems to only happen to me when I'm using nUnit. Try this AppDomain.CurrentDomain.SetupInformation.ConfigurationFile Hope it helps Strictly speaking, there is no single configuration file.

How to check if an appSettings key exists?

只愿长相守 提交于 2019-11-27 10:03:35
问题 How do I check to see if an Application Setting is available? i.e. app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key ="someKey" value="someValue"/> </appSettings> </configuration> and in the codefile if (ConfigurationManager.AppSettings.ContainsKey("someKey")) { // Do Something }else{ // Do Something Else } 回答1: MSDN: Configuration Manager.AppSettings if (ConfigurationManager.AppSettings[name] != null) { // Now do your magic.. } or string s =