app-config

What happen if I delete App.config in C# application?

烂漫一生 提交于 2019-12-03 05:08:18
I write a small application, that I don't need store anything in config files. So the file App.config in my source is exactly what ever Visual Studio has created. So I want to delete this file from source code (before compiling). But I noticed that it also contains the .NET version information. I wonder if I delete App.config file, then copy my application to other pc, is it have any strange behavior? I wonder if I delete App.config file, then copy my application to other pc, is it have any strange behavior? Nope, it should be fine. There are various (somewhat tortuous) rules about exactly

How do I read/write App.config settings with PowerShell?

こ雲淡風輕ζ 提交于 2019-12-03 05:06:12
问题 I'd like to use PowerShell as part of our automated build process to update an App.config file while deploying into our test environment. How can I do this? 回答1: The code can be much more shorter (based on Robin's app.config): $appConfig = [xml](cat D:\temp\App.config) $appConfig.configuration.connectionStrings.add | foreach { $_.connectionString = "your connection string" } $appConfig.Save("D:\temp\App.config") 回答2: Given this sample App.config: C:\Sample\App.config: <?xml version="1.0"

Get filename of current configuration file

半腔热情 提交于 2019-12-03 04:16:34
I'd think this would be simple, but I can't find an answer. I'm using remoting and I want to store the RemotingConfiguration in the app.config. When I call RemotingConfiguration.Configure I have to supply the filename where the remoting information resides. So... I need to know the name of the current configuration file. Currently I'm using this: System.Reflection.Assembly.GetExecutingAssembly().Location + ".config" But this only works for windows applications, not for web applications. Isn't there any class that can supply me with the name of the current config file? Paul Alexander Try

Azure Worker Role Config File Transformations

混江龙づ霸主 提交于 2019-12-03 02:53:16
I've setup a new worker role and setup a couple of new config transforms for it via SlowCheetah. When I build the project with one of the new configs selected, I do in fact see that configs folder get created underneath the \bin folder as you would expect (for ex. \bin\Production). When I package a cloud service for deployment using one of the new configs, my web projects get their configs transformed appropriately but my worker role (which is just a library) does not even though I see underneath the \bin folder an updated \bin\production. It would appear the azure packaging tooling is

Reading keyvalue pairs into dictionary from app.config configSection

那年仲夏 提交于 2019-12-03 02:38:41
问题 I currently have an app.config in an application of mine set up like so: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="DeviceSettings"> <section name="MajorCommands" type="System.Configuration.DictionarySectionHandler"/> </sectionGroup> </configSections> <appSettings> <add key="ComPort" value="com3"/> <add key="Baud" value="9600"/> <add key="Parity" value="None"/> <add key="DataBits" value="8"/> <add key="StopBits" value="1"/> <add key="Ping"

ConfigurationManager.AppSettings Returns Null In Unit Test Project

荒凉一梦 提交于 2019-12-03 01:41:34
I have a C# unit test project with application settings in the app.config file. I am testing a class that exists in a different project. That class depends on both, ConfigurationManager.AppSettings and ConfigurationManager.ConnectionStrings . The project that the class being tested resides in does not have an app.config file. I would have thought that because the class is being instantiated in the context of the unit test project that it would use the unit test project's app.config file. Indeed, that does seem to be the case for the connection string. The class retrieves the connection string

App config for dynamically loaded assemblies

狂风中的少年 提交于 2019-12-03 00:52:50
I'm trying to load modules into my application dynamically, but I want to specify separate app.config files for each one. Say I have following app.config setting for main app: <appSettings> <add key="House" value="Stark"/> <add key="Motto" value="Winter is coming."/> </appSettings> And another for library that I load using Assembly.LoadFrom : <appSettings> <add key="House" value="Lannister"/> <add key="Motto" value="Hear me roar!"/> </appSettings> Both libraries have a class implementing the same interface, with the following method: public string Name { get { return ConfigurationManager

Changing the .NET application configuration file name

大城市里の小女人 提交于 2019-12-03 00:06:58
I have a VB6 app which calls a .NET assembly, which references settings from the app.config file. By default, .NET looks for a config file named after the VB6 app. How can I redirect it to use a different config file name? This needs to become the default config file so that e.g. WCF settings are read from it. You can't change it. Each AppDomain instance has a fixed app.config that is set via an AppDomainSetup instance when a new app domain is created. Although you can get the setup information via AppDomain.SetupInformation it has effectively become readonly at this point. Given this, one

app.config — How to force load from file at runtime?

房东的猫 提交于 2019-12-02 21:24:27
问题 I created a command-line application and moved a lot of its config into a standard Settings file. All settings are declared as Scope = Application, because there is nothing user-specific about the logic in the application. I access the values throughout the code with Properties.Settings.Default.<whatever> This works well as it runs automatically on a schedule. Updating values in the config file are reflected in the output. Some time later, I created a basic GUI (in the same namespace) to

Should Unity be configured in code or configuration file?

巧了我就是萌 提交于 2019-12-02 19:17:44
Microsoft's Unity dependency injection framework can be configured either through code or through the applications configuration file (app.config). Code example: IUnityContainer container = new UnityContainer() .RegisterType<IInterface, ConcreteImplementation>(); Configuration example: <unity> <containers> <container> <types> <type type="IInterface, MyAssembly" mapTo="ConcreteImplementation, MyAssembly" /> What are the advantages/disadvantages to each approach? I can think of the obvious advantage "Users can easily configure your application", and the obvious disadvantage "Users can easily