app-config

Custom Configuration for app.config - collections of sections?

独自空忆成欢 提交于 2019-11-30 13:04:31
My head is absolutely pounding badly! I have done this before but not as "in depth" or complex as this and I have tried different ways to make this happen but all has failed. So, this is the custom XML I want in the app.config: <Profiles> <!--Collection--> <Profile Name="Live"> <Components> <Component Name="Portal" Type="Web" /> <Component Name="Comms" Type="Web" /> <Component Name="Scheduler" Type="WindowsService" ServiceName="LiveScheduler" /> </Components> <Databases> <Database Name="Main" Connection="Data Source=.\SQL2008" /> <Database Name="Staging" Connection="Data Source=SomeSite.co.uk"

C# Set probing privatePath without app.config?

瘦欲@ 提交于 2019-11-30 11:58:56
I have a C# application, and to organize its files I have some DLL's in a folder called "Data". I want the EXE to check this folder for the DLL's just like how it checks its current directory. If I created a App.Config with this information: <?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="Data" /> </assemblyBinding> </runtime> </configuration> It works without a problem. I do not want to have an App.Config. Is there a way to set the probing path without using an app.config? You can do it for new

Custom config section containing collection

佐手、 提交于 2019-11-30 11:51:07
I'm having trouble getting a custom config section to work. It's some code I got from the web in an effort to try to understand this area a little better and enable me to get to where I want to ultimatly be, my own custom config section. The error I get when I run the code in a console app is ' Unrecognized attribute 'extension'. Note that attribute names are case-sensitive. ' The code in the main app to get things going is var conf = ConfigurationManager.GetSection("uploadDirector"); and this is where the exception appears. This is the config section I am hoping/trying to achieve

How do you instruct NUnit to load an assembly's dll.config file from a specific directory?

╄→гoц情女王★ 提交于 2019-11-30 11:43:56
If an assembly contains an app.config file, ConfigurationManager will load it as long as it is in the same directory as the NUnit project that is executing through NUnit-Gui. To illustrate consider the following folder structure. + TestFolder testProject.nunit + AssemblyAFolder assemblyA.dll assemblyA.dll.config + AssemblyBFolder assemblyB.dll assemblyB.dll.config Both AssemblyA and AssemblyB exercise code that calls into ConfigurationManager . If I run these test assemblies independently in NUnit-Gui, ConfigurationManager will correctly resolve the local configuration files. However, if I

Deploying connection string encrypted via RSAProtectedConfigurationProvider in app.config

不羁岁月 提交于 2019-11-30 10:16:13
If a developer encrypts a connection string app.config section using RSAProtectedConfigurationProvider on their own machine, and this is subsequently deployed to a user's workstation, can that user's workstation (or server, for that matter), decrypt the connection string automatically? Would some kind of key export/installation be required? How does this work? I realize that it's not bulletproof. I'm looking for advice on whether or not the deployment would be easy and/or work with such an encrypted connection string. It is possible. There are APIs to do it (look at the System.Security

How to Save Configuation in app.config in C# Winforms

可紊 提交于 2019-11-30 09:23:10
Can someone give me an example of how to save a key/value in app.config using C# and WinForms? Edwin Tai In ASP.NET : Configuration config = WebConfigurationManager.OpenWebConfiguration(null); AppSettingsSection app = config.AppSettings; app.Settings.Add("x", "this is X"); config.Save(ConfigurationSaveMode.Modified); In WinForms : Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); AppSettingsSection app = config.AppSettings; app.Settings.Add("x", "this is X"); config.Save(ConfigurationSaveMode.Modified); I know you specifically asked for WinForms

Multiple SQL Server connection strings in app.config file

依然范特西╮ 提交于 2019-11-30 08:09:57
问题 I'm interested in displaying in a Windows Forms app a list of N radio buttons for the user to choose a target database server. I would like to add the SQL Server connection strings in the app.config file, so they are read by the app at runtime and rendered in the windows form as radio buttons. At first I thought of using a delimiter to separate the connections <appSettings> <add key="ConnectionString" value="connection1|user id=user;password=123;server=10.0.0.1;database=myDatabase;connection

The problem with NUnit and app.config

谁说胖子不能爱 提交于 2019-11-30 08:08:13
When i run a simple test on connection to DB check i receive an error in NUnit: [Test] public void TestConn() { string connectionString = ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); Assert.AreEqual(ConnectionState.Open, connection.State); connection.Close(); } System.NullReferenceException : Object reference not set to an instance of an object. on line : connectionString = ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString; Can i use ConfigurationManager in

Do not overwrite settings.settings file with clickonce

旧时模样 提交于 2019-11-30 07:42:41
问题 At first I had some userdefined settings stored in my app.config file, under appSettings. These are properties the user can change during runtime. The first problem I've got is when I deploy my application with ClickOnce it overwrites the app.config file and the user has lost his personal settings. Then I moved the properties to the settings.settings file (= usersettings section in app.config) as I found on the internet that this section doesn't get overwritten when deploying with ClickOnce.

Get the file path of current application's config file

a 夏天 提交于 2019-11-30 06:48:26
The reason I asked this question is that I wanted to create a helper class for Remoting instantiation, and wanted to pass the appropriate app.exe.config (or web.config) file path to the RemotingConfiguration.Configure method, depending on the caller. Is there a way I could get the name of the config file for both Win and Web apps without checking if the application is Web or WinForms? I've used string folder = System.Web.HttpContext.Current != null ? System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_data") : System.IO.Path.GetDirectoryName(System.Reflection.Assembly