app-config

How to define DataDirectory for ConnectionString in console application to work with EntityFramework Code First Migrations

末鹿安然 提交于 2019-11-29 03:05:24
问题 I try to set location MyProject\App_Data\Cos.mdf for the database in App.config : <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Cos.mdf;Initial Catalog=Cos;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> </connectionStrings> In Program.cs I wrote: static void Main(string[] args) { string relative = @"..\..\App_Data\Cos.mdf"; string absolute = Path.GetFullPath

If app.config for a DLL should be in the “main config”… what do we do with WCF References in DLLs?

那年仲夏 提交于 2019-11-29 02:42:17
问题 Ok, this is rather simple, but from what I've seen… you can only use some sort of Windows Workflow to include another config into another (which I refuse to do). Here's the deal: MAINAPP.EXE References an hypothetical LIBRARY.DLL. MAINAPP.EXE has its own MAINAPP.EXE.config. If you add "config values" to LIBRARY.DLL (thereby creating an app.config in LIBRARY.DLL project), those values are not available at runtime even if you copy app.config into LIBRARY.DLL.config to the right path post-build

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

狂风中的少年 提交于 2019-11-29 02:07:13
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.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.File = "App2.config"; Michael See

How to save application settings in a config file?

家住魔仙堡 提交于 2019-11-28 23:59:21
I am developing a program that has a settings window in which I can change various parameters for my program. What is the best way to read/save them in some kind of config file? I know that some software and games use .ini files or similar system. How can I achieve this in Python? The Python standard library includes the ConfigParser module , which handles ini-style configuration files for you. It's more than adequate for most uses. Another popular option for configuration files is JSON - it's a simple notation which has good support from a wide range of languages. Python has the json module

How to change location of app.config

天涯浪子 提交于 2019-11-28 23:57:43
I want to change the location where my application looks for the app.config file. I know that I can use ConfigurationManager.OpenExeConfiguration() to access an arbitrary config file - however, when the .Net Framework reads the config file (for ConnectionStrings or EventSources, for instance), it will look at the default location. I want to actually change the location, globally for the entire .Net Framework (for my application, of course). I also know that I can use AppDomainSetup to change the location of the app.config for a new AppDomain. However, that doesn't apply to the primary

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

社会主义新天地 提交于 2019-11-28 23:38:38
How to load application settings to NHibernate.Cfg.Configuration object by using System.Configuration.ConfigurationManager from App.config? 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"].ToString(); NHibernate.Cfg.Configuration nHibernateConfiguration = new NHibernate.Cfg.Configuration();

CloudConfigurationManager.GetSetting returning null

空扰寡人 提交于 2019-11-28 23:09:44
Following instructions here I have: var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString"); But connectionString is null , here is my app.config: <?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <connectionStrings> <add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=https;AccountName=storage;AccountKey=key" /> </connectionStrings> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name=

.NET - deploying a WCF client, without an app.config

别等时光非礼了梦想. 提交于 2019-11-28 22:01:33
问题 I'm writing a client to a WCF service. This is a single app in a larger system that includes modules written in C#, C++, VB, and Java. All of the apps share common configuration and logging mechanisms, regardless of what language they were written in. I'd like to figure out how to build the client application so that it will run without an app.config. Why? Because most of what is in the app.config is boilerplate that the sysadmins shouldn't be allowed to change, and what settings the

Open other program's configuration files

拈花ヽ惹草 提交于 2019-11-28 21:37:33
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 OpenExeConfiguration method, and passing the program A's filename as an argument. But it throws and exception of

Centralize connection strings for multiple projects within the same solution

。_饼干妹妹 提交于 2019-11-28 21:34:26
I currently have three projects in my solution that all have their own App.config file with the same exact connection string. Is there a way to consolidate the connections strings / app.config files so that I only need to make changes to one location? There's a few ways you could do it: Put common configuration settings in machine.config as shown here Put common configuration settings in a central file and link to that in each projects's app.config as shown here Store the configuration settings in the registry For me, i always work with the last solution :) Good luck! You can share the