app-config

Get user and password from ConnectionStringSettings

隐身守侯 提交于 2019-12-22 01:33:35
问题 How can I get the user and password from such a connectionString in the app.config with a .NET function? Of course I could read that string and get the value after the ID= and Password=. <connectionStrings> <add name="MyConString" connectionString="Data Source=(local);Initial Catalog=MyDatabase;Persist Security Info=True;User ID=MyUsername Password=MyPassword;Connect providerName="System.Data.SqlClient"/> </connectionStrings> 回答1: use the ConnectionBuilderClass SqlConnectionStringBuilder

exePath must be specified when not running inside a stand alone exe

↘锁芯ラ 提交于 2019-12-22 01:12:52
问题 When i am using a web application, the line of code below Configuration objConfig = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); in class library are giving this error: "exePath must be specified when not running inside a stand alone exe." Previously a console application was being used, and the code could access the app.config . I tried using the System.Web.Configuration in class library but the dll was not present in the .Net tab for "Add reference". Kindly help

How to set up a WCF client using wsDualHttpBinding in code?

别等时光非礼了梦想. 提交于 2019-12-21 10:16:29
问题 I have a need to connect to a WCF service I wrote without having to deploy an app.config for the client application I'm writing. However, I've been having a very difficult time trying to figure out how to set up things from the client side in code. This is as far as I've gotten... does anyone have any ideas what I need to do to get this to work? I'd really appreciate it. This is the code I've got so far: String baseAddress = "http://localhost/CommService"; WSDualHttpBinding binding = new

Exception when specifying defaultProxy in app.config when running NET4.0 application from network share

◇◆丶佛笑我妖孽 提交于 2019-12-21 07:57:08
问题 We're seeing a very strange issue when running the following application from a network share under NET4.0. When specifying a defaultProxy section in app.config a System.Net.WebException is thrown. There is no problem when running from a local drive. According to documentation applications will run as full-trust assemblies from a network share so we're assuming this should work just fine. Any ideas how we can work around this problem? Has anyone else experienced this issue or does anyone know

How to prevent a Phonegap application to switch to landscape view

倖福魔咒の 提交于 2019-12-21 03:16:08
问题 This one should be very simple, however it's not. I'm trying to prevent my application from going into landscape view so I've changed the config.xml file like this: <preference name="orientation" value="portrait" /> . Unfortunately, it's not working. Any ideas? 回答1: Ok, so I got it: The reason Phonegap ignored the <preference name="orientation" value="portrait" /> in the config.xml file is because my app was in debug mode. once I created a release version it stopped from going to landscape.

What does “SKU” (attribute) mean in C#?

Deadly 提交于 2019-12-21 03:12:30
问题 Today I encountered with the line <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> in my App.config file which caused errors with framework when the sku attribute was included. Although, I searched a lot I couldnt really find out what SKU means (other than the definitions "stock keeping unit" or "Shelf Keeping Unit" which I dont think are related to this case). In short, what does SKU mean/stand for ? 回答1: See the msdn documentation about the supportedRuntime element. It

How can multiple elements be added to an XML config file with wix?

和自甴很熟 提交于 2019-12-21 01:39:13
问题 I am trying to edit an XML file with Wix. I am using the WixUtilExtension bundled with Wix 3.7. The xml file is a settings file created in Visual Studio 2010 for a C# application. In this file, I am using an element which is used to store multiple string values in an array. This is the content of the unaltered settings file: <configuration> <applicationSettings> <AppName.Properties.Settings> <setting name="StringArray" serializeAs="Xml"> <value> <ArrayOfString xmlns:xsi="http://www.w3.org

Changing the .NET application configuration file name

戏子无情 提交于 2019-12-20 10:44:02
问题 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. 回答1: 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

Should Unity be configured in code or configuration file?

走远了吗. 提交于 2019-12-20 09:37:39
问题 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

Why do people consistently recommend using appConfig instead of using Settings files? (.NET)

你离开我真会死。 提交于 2019-12-20 08:11:19
问题 Very often I see the answer to the question like: "How should I store settings in my .NET app?" is to edit the app.config file by manually adding entries to the app.config (or web.config) like so: <configuration> <appSettings> **<add key="ConfigValueName" value="ABC"/>** </appSettings> </configuration> Then, accessing them like: string configValue = Configuration.AppSettings["ConfigValueName"]; I'll refer to the approach outlined above as the "app.config" approach. Very rarely do I see people