app-config

Do I need to escape backslash in a config file?

扶醉桌前 提交于 2020-01-10 03:32:05
问题 I have a config file, myapp.exe.config. In the file I have an attribute with a fullpath filename as the value. <add key="InfoFile" value="c:\temp\info.txt" /> It seems to work if I use a single or double backslash. That is, <add key="InfoFile" value="c:\\temp\\info.txt" /> works also. What is the correct way to do this? 回答1: You don't need that. Anything within an attribute value is character data. Since you're reading these values using C#, they'll get escaped as if they would be a literal

Powershell Calling .NET Assembly that uses App.config

耗尽温柔 提交于 2020-01-09 04:22:05
问题 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

is app.config file in WinForms cached by .Net framework?

纵饮孤独 提交于 2020-01-06 08:24:08
问题 I was wondering if someone can confirm that App.Config file is cached by CLR in the AppDomain and not read everytime you try to read the value? 回答1: It is loaded at start-up. Reads will reflect whatever the app.config file said at that point. 来源: https://stackoverflow.com/questions/5822225/is-app-config-file-in-winforms-cached-by-net-framework

Change the store location of application setting file [duplicate]

◇◆丶佛笑我妖孽 提交于 2020-01-05 08:01:33
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Using ConfigurationManager to load config from an arbitrary location I'm using Setting File to store my application's settings. The setting file will be stored in %AppData%\CompanyName\user.config. How to change store location? Example: I want to save this config file in %AppData%\CompanyName\ApplicationName\Version\user.config Thanks. 回答1: You might decide to use .NET per-user(roaming) settings: Configuration

App Config - The Login is from an untrusted domain

狂风中的少年 提交于 2020-01-05 04:30:30
问题 First, I try to connect to sql server of other computer(PC1-PC\Instance1) through ssms with Windows Authentication but got this error Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. I resolve the error when I edit the password of sa to 1234 in PC1-PC\Instance1. Then connect in the ssms with SQL Server Authentication. And successfully connected. The problem is in my Winforms app config, I set the connection to this: <connectionStrings> <add

How do I run app.config transformation task first before the PostBuildEvents?

只愿长相守 提交于 2020-01-04 06:45:50
问题 I have a console application that uses a database connection string which is defined in app.config. I have a few transformations to change the string depending on the build configuration. I also have a few post-build events that copy app.config to other projects output. The problem is post-build event fires first and I copy the untransformed app.config. Later the transformation task kicks in and apply the transformation (so I know it works). I use with Visual Studio 2010 and .NET 4. Right now

Calling Connection string from App setings app.config file to C# code

匆匆过客 提交于 2020-01-04 05:23:09
问题 I'm trying to call a connection string from the app.config file to C# code. This is the app.config code: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="connectstring" value="Data Source=server111;Initial Catalog=database1; Integrated Security=False;Persist Security Info=False; User ID=username;Password=password;Encrypt=True; TrustServerCertificate=True; MultipleActiveResultSets=True"/> </appSettings> </configuration> This is the C# code: private SqlConnection

Why is this class library dll not getting information from app.config

 ̄綄美尐妖づ 提交于 2020-01-04 04:12:28
问题 I am developing a custom HttpHandler, to do so I write a C# Class Library and compile to DLL. As part of this I have some directory locations which I want not hard coded in the app, so i'm trying to put it in the app.config which I've used before. Before this has worked by just going building the app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Share" value="C:\...\"/> </appSettings> </configuration> And then obtaining this in code like: var

app.config modify value c#

旧街凉风 提交于 2020-01-03 16:59:40
问题 The question is addressed here App.Config change value The accepted answer is string appPath = System.IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly().Location); string configFile = System.IO.Path.Combine(appPath, "App.config"); ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); configFileMap.ExeConfigFilename = configFile; System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel

Why would adding an **appSettings** section to App.config cause an error in WPF application?

回眸只為那壹抹淺笑 提交于 2020-01-03 16:45:58
问题 In my WPF application (Composite Application) I want to store a variable in the App.config file, but as soon as I add an appSettings section in App.config, it gives me this error: The type initializer for System.Windows.Application threw an exception. App.Config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="SmartFormMockDirectory" value="C:\test"/> </appSettings> <configSections> </configSections> <system.serviceModel> <bindings> <basicHttpBinding> <binding