app-config

Do binding redirects in app.config for class libraries do anything?

…衆ロ難τιáo~ 提交于 2019-12-02 18:46:00
The VS solutions I often work with consist of a single executable project (console app, web app) and many class library projects that are all referenced by the executable. When working with NuGet and installing packages, there's often an app.config file created for each project, usually containing nothing else than a list of binding redirects that consolidate versions of referenced assemblies. Sometimes there's some third-party library-specific content (like Entity Framework config section), but let's leave that aside for now. When I build the solution and use the binaries of the main

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

拜拜、爱过 提交于 2019-12-02 17:31:55
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? 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") Given this sample App.config: C:\Sample\App.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="dbConnectionString" connectionString="Data Source=

How to display a login failure messagebox for App.Config connection string

不想你离开。 提交于 2019-12-02 16:29:46
问题 I use the following connection string and am able to log into SQL 2008 R2 Server. My.Settings.Item("CustomerConnectionString") = "Data Source=FAROOK-PC\SQLEXPRESS;Initial Catalog= '" & Me.ComboBox1.Text & "'; uid = '" & Me.Login1.Text & "'; pwd = '" & Me.Password1.Text & "'" How do I display a messagebox on login failure. Thank you. 回答1: use Try Catch Block. If connection fails use yor message box in catch block. Dim sqlCnn As New SqlConnection Dim connString as string = "Your Connection

Reading keyvalue pairs into dictionary from app.config configSection

痞子三分冷 提交于 2019-12-02 16:13:09
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" value="*IDN?"/> <add key="FailOut" value="1"/> </appSettings> <DeviceSettings> <MajorCommands> <add key=

where does a .net Winform's application's app.config file reside..?

心不动则不痛 提交于 2019-12-02 15:34:18
问题 As per this link we can add node in app.confi file. http://msdn.microsoft.com/en-us/library/ff602939.aspx so, where does that file exist? If i have given some exe to some one , can I later give him a app.config and ask them to place in the right location - so, that application functions accordingly..? My app is C# .net 2.0. 回答1: In the same folder as the exe. Note the app.config file should be the same name as the exe with a .config stuck at the end. That is, if you had a program fooBar.exe ,

Custom Configuration Section can only be saved/modified while running as administrator?

馋奶兔 提交于 2019-12-02 12:42:04
问题 I wrote a custom configuration section, collection, and element to add/modify to my app.config. All seems to be going well and it works perfectly running in Visual Studio. However, when I install the application and it comes time to save the new data to the custom config section, the following exception is thrown: System.Configuration.ConfigurationErrorsException: Unable to save config to file '{path to config file}' The interesting part is that if I run the application in administrator mode,

where does a .net Winform's application's app.config file reside..?

有些话、适合烂在心里 提交于 2019-12-02 12:03:38
As per this link we can add node in app.confi file. http://msdn.microsoft.com/en-us/library/ff602939.aspx so, where does that file exist? If i have given some exe to some one , can I later give him a app.config and ask them to place in the right location - so, that application functions accordingly..? My app is C# .net 2.0. In the same folder as the exe. Note the app.config file should be the same name as the exe with a .config stuck at the end. That is, if you had a program fooBar.exe , the config file should be named fooBar.exe.config . 来源: https://stackoverflow.com/questions/11456784/where

List<T> overwrites all the items inside a foreach loop to the last value

为君一笑 提交于 2019-12-02 11:56:31
问题 I'm trying to build a windows application in which there is a combo box and during the Load(), I'm population this combo box with all the connection strings availabe in my app.Config file. Here is the app.Config snippet: <!-- Adding Multiple Servers in Connection String--> <connectionStrings> <add name="SQLConnect-1" connectionString="Data Source=SAHIL; Initial Catalog=RecordComparisonTool; Integrated Security=SSPI" providerName="System.Data.SqlCLient"/> <add name="SQLConnect-2"

How to display a login failure messagebox for App.Config connection string

蓝咒 提交于 2019-12-02 08:58:15
I use the following connection string and am able to log into SQL 2008 R2 Server. My.Settings.Item("CustomerConnectionString") = "Data Source=FAROOK-PC\SQLEXPRESS;Initial Catalog= '" & Me.ComboBox1.Text & "'; uid = '" & Me.Login1.Text & "'; pwd = '" & Me.Password1.Text & "'" How do I display a messagebox on login failure. Thank you. use Try Catch Block. If connection fails use yor message box in catch block. Dim sqlCnn As New SqlConnection Dim connString as string = "Your Connection String" Try sqlCnn = New SqlConnection(connString) sqlCnn.open() Catch ex As SqlException MsgBox("Login Failed")

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

廉价感情. 提交于 2019-12-02 08:44:33
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 launch the command-line application directly (through a separate constructor). I haven't done a huge amount