app-config

Accessing app.config in ASP.NET

▼魔方 西西 提交于 2019-12-01 19:32:50
I am using app.config file to read data from it.. I am loading the app.config file as: string app_path = HttpContext.Current.Server.MapPath("app.config"); xmlDoc.Load(app_path); string image_path = ConfigurationManager.AppSettings["Test1"]; and i want to get the value of "Test1". But the value of test1 is comming "null".. how can i get the value of "test1" from app.config file.. i created the app.config file as: <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="Test1" value="My value 1" /> <add key="Test2" value="Another value 2" /> </appSettings> </configuration>

Configuration from App.config isn't being pulled correctly

纵然是瞬间 提交于 2019-12-01 19:05:45
问题 I'm trying to extract a URL I saved to the app.config file, but it's returning a blank string. Any ideas why? string asdf = String.Format("{0}", ConfigurationManager.AppSettings["MemberUrl"]); And the configuration file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="ForumUrl" value="http://www.dreamincode.net/forums/xml.php?showforum=" /> <add key="MemberUrl" value="http://www.dreamincode.net/forums/xml.php?showuser=" /> </appSettings> </configuration> 回答1:

What steps do I need to take to convert from a class library to a WCF?

守給你的承諾、 提交于 2019-12-01 18:12:15
I created a project as a Class Library. Now I need to make it into a WCF. I can create a WCF project, but I would like to avoid all that fuss with TFS. I've done the App.config and added the /client:"wcfTestClient.exe" line to the Command line arguments. But there seems to be something else missing from it launching the Hosting. Dog Ears I discovered the following doing the opposite to what you are trying to achieve, i.e. changing a service library to a console application.. some of the settings in the csproj files cannot be edited from the settings screen from within VS to convert an class

Persisting the data in app.config between debugging sessions

做~自己de王妃 提交于 2019-12-01 16:54:05
So, long story short, I'm developing an application that will make use of some configuration info that may be changed at runtime through the application itself. For the purpose I've thought of using the Settings class. The problem, thought, is that information is not persisted between different runs of the application: Run 1) Console.WriteLine(Settings.Default["User"]); //prints "Default user" Settings.Default["User"] = "abc"; Console.WriteLine(Settings.Default["User"]); //prints "abc" Run 2) Console.WriteLine(Settings.Default["User"]); //prints "Default user" Settings.Default["User"] = "abc";

How can I make LINQ to SQL use a connection string which is being modified at runtime?

老子叫甜甜 提交于 2019-12-01 16:31:50
I'm experimenting some difficulties trying to use Connection String Builders (ADO.NET) within LINQ to SQL. Let me show you guys what I'm trying to do: the app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> </configSections> <connectionStrings> <add name="LoremIpsum" connectionString="Data Source=SomeServer;Initial Catalog=SomeDB;User ID=joe;" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> and a snippet of the form: ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["LoremIpsum"]; if (null != settings)

How can I make LINQ to SQL use a connection string which is being modified at runtime?

邮差的信 提交于 2019-12-01 15:40:51
问题 I'm experimenting some difficulties trying to use Connection String Builders (ADO.NET) within LINQ to SQL. Let me show you guys what I'm trying to do: the app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> </configSections> <connectionStrings> <add name="LoremIpsum" connectionString="Data Source=SomeServer;Initial Catalog=SomeDB;User ID=joe;" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> and a snippet of the form:

C# App.config vs Settings File

大憨熊 提交于 2019-12-01 14:59:45
This may sound like a trivial question, however I have looked over the web briefly and what I found was that app.config is basically an older mechanism for storing Application key/pairs of data for the application. What I want to know is there any reason we (as .NET developers) would opt to use app.config over a Settings file ? -Can someone please provide some pros and cons on both so we can use them properly. thanks again App.config for desktop applications and Web.config for web applications are part of .NET configuration system. Primarily they are used to control .NET framework settings in

Encrypting config files for deployment .NET

橙三吉。 提交于 2019-12-01 14:45:31
I have a windows service that reads from app.config I want some settings to be encrypted, however, I don't want to use the ProtectedConfigurationProvider classes provided in .NET because they encrypt files based on the machine they are running on using DPAPI. What I wanted was a way for our administrator to deploy the config file already encrypted to many machines and have each machine decrypt them when needed. I don't want to hardcode a password into the assembly either so I'm not sure how I can go about this. Perhaps your central server can maintains a database of the private keys for all

Unable to create a custom section for web.config

我与影子孤独终老i 提交于 2019-12-01 13:32:22
问题 I created a custom section in the web.config file but it isn't able to load my custom type that is going to manage the section. Here are the definitions: <configSections> <section name="MembershipProviders" type="MyApp.BusinessObjects.MembershipProviderFactory.MembershipProvidersSection" allowLocation="true" allowDefinition="Everywhere" /> </configSections> namespace MyApp.BusinessObjects { public class MembershipProviderFactory { internal virtual IMembershipProvider Create() { } public class

Encrypting config files for deployment .NET

流过昼夜 提交于 2019-12-01 12:50:15
问题 I have a windows service that reads from app.config I want some settings to be encrypted, however, I don't want to use the ProtectedConfigurationProvider classes provided in .NET because they encrypt files based on the machine they are running on using DPAPI. What I wanted was a way for our administrator to deploy the config file already encrypted to many machines and have each machine decrypt them when needed. I don't want to hardcode a password into the assembly either so I'm not sure how I