app-config

.net dynamically refresh app.config

心不动则不痛 提交于 2019-11-27 12:41:37
How do I dynamically reload the app.config in a .net Windows application? I need to turn logging on and off dynamically and not just based upon the value at application start. ConfigurationManager.RefreshSection("appSettings") does not work and I've also tried explicitly opening the config file using OpenExeConfiguration but I always get the cached value at application startup and not the current value. I've accepted the answer of creating a custom configuration section. As a side note and foolish mistake - if you're running from the IDE there's no point in updating the app.config file and

Powershell Calling .NET Assembly that uses App.config

爱⌒轻易说出口 提交于 2019-11-27 11:42:51
I have a Powershell script that is loading a .NET assembly (.EXE in my case) and calling a public method that uses the app.config to pull an encrypted connection string. The script dynamically copies the assembly's exe.config over to the Powershell ($pshome) folder as powershell.exe.config and is able to run from my development box just fine. The problem is that it doesn't run from a standard Windows Server 2003 installation. I verified the exe.config is being copied over to the powershell directory correctly. I've run SysInternals Process Explorer and verified that the process was accessing

Consume a SOAP web service without relying on the app.config

蹲街弑〆低调 提交于 2019-11-27 11:28:26
I'm building a .NET component that will call an external web service. I used the "Add Service Reference" dialog to add the web service to my component, which generates the code needed to consume the service and adds the settings to the app.config file. I'm testing the component by adding a reference to its DLL from a Console application and calling the appropriate method that creates a new instance of the web service: ... = new MyServiceSoapClient() . However, when I do this, I get the following exception: InvalidOperationException Could not find default endpoint element that references

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.

Enabling Intellisense for Custom Sections in .config Files

爱⌒轻易说出口 提交于 2019-11-27 09:41:20
问题 When editing .NET config files (app.config, web.config, etc) in Visual Studio, I get Visual Studio's intellisense to guide me when choosing my application's settings. If I add a custom configuration section, how can I enable intellisense for my custom settings? I'm sure there must be an easy answer to this, but a cursory Google search didn't give me any help. Thanks! 回答1: If you do not want to modify your Visual Studio files or copy anything into the Visual Studio folder, you can add the .xsd

Settings.settings vs. app.config in .NET desktop app [duplicate]

坚强是说给别人听的谎言 提交于 2019-11-27 09:15:42
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is the difference between app.config file and XYZ.settings file? I am quite confused by the apparent redundancy of these two mechanisms in Visual Studio to store and manage desktop application settings: You can use the XML app.config file, adding items to the <appSettings> section. These can be retrieved from code using the ConfigurationManager class. Alternatively, you can use the Settings.settings file to

How to enable configSource attribute for Custom Configuration Section in .NET?

我的未来我决定 提交于 2019-11-27 08:50:12
following the wealth of information found here how can we get an external .config to work? I've tried the same setup I would use for an external appSettings file, but it is unable to find the file for my custom section. <configSections> ... <section name="CustomSettings" type="Fully.Qualified.TypeName.CustomSettings, AssemblyName" /> </configSections> <!-- this works --> <CustomSettings attrib1="val1" attrib2="val2" .../> however... <!--this does not work--> <CustomSettings configSource="someExternalFile.config"/> where someExternalFile.config would contain <CustomSettings attrib1="val1"

How do I set CultureInfo.CurrentCulture from an App.Config file?

谁说胖子不能爱 提交于 2019-11-27 08:49:15
I need to set my application's culture through an App.Config file, so that "pt-BR" is used automatically for parsing dates without the need to manually inform the culture for each operation. As far as I know, there's a globalization section that can be defined inside the system.web section in a Web.Config file, but I'm running a console application and I can't figure this out. Any idea? Adi Lester I don't know a built-in way to set it from App.config, but you could just define a key in your App.config like this <configuration> <appSettings> <add key="DefaultCulture" value="pt-BR" /> <

Changing App.config at Runtime

风流意气都作罢 提交于 2019-11-27 08:30:30
I'm writing a test WinForms / C# / .NET 3.5 application for the system we're developing and we fell in the need to switch between .config files at runtime, but this is turning out to be a nightmare. Here's the scene: the WinForms application is aimed at testing a WebApp, divided into 5 subsystems. The test process works with messages being sent between the subsystems, and for this process to be successful each subsystem got to have its own .config file. For my Test Application I wrote 5 separate configuration files. I wish I was able to switch between these 5 files during runtime, but the

Is there any way for an App.config file to reference another full config file? (.NET)

て烟熏妆下的殇ゞ 提交于 2019-11-27 07:54:04
Update: this question, including the title, was rephrased, see history for details I know that the following App.config includes a external file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings configSource="appSettings.config"/> <system.net> <connectionManagement> <add address="*" maxconnection="50"/> </connectionManagement> </system.net> </configuration> But I don't know how to move the system.net to the second file. Actually I haven't tried it, but I am almost certain that it will not work, and I want to know if there is an way for an App.config to include another App