appsettings

wpf - Get values from App Config file

好久不见. 提交于 2019-12-21 12:12:07
问题 How to get values from App.Config. Code: <configuration> <appSettings> <add key="ShowRoomCode" value="1000"/> <add key="FolderPath" value="D:\\Images\\Book\\"/> </appSettings> </configuration> string imageFolderPath = ConfigurationManager.AppSettings["FolderPath"]; But it returns null value. Config file is in the Same project. 回答1: If you expand the Properties section of Visual Studio and double click the settings section, you will be able to add custom settings which end up like so in the

Using appsettings in the DAL layer

血红的双手。 提交于 2019-12-21 05:12:24
问题 I have a winforms application in which some of the data is stored in XML files. The location where these XML files should be stored can be configured by the user, and is stored in the AppSettings. All my layers are separate assemblies. Can I access my settings from my DAL assembly, or should I pass this as an argument through all my layers? When I try to read the settings from my DAL layer, I encounter another problem Configuration config = ConfigurationManager.OpenExeConfiguration( System

Unable to set my connectionstring in NLog

廉价感情. 提交于 2019-12-21 03:49:20
问题 The NLog.config file does not set the connection string. <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Warn" internalLogFile="c:\temp\internal-nlog.txt"> <!-- Load the ASP.NET Core plugin --> <extensions> <add assembly="NLog.Web.AspNetCore" /> </extensions> <variable name="SirNLogDb" value="data source=SQL_MULALLEY;initial catalog=LogFiles;User ID=xxx

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

MS Access Database Connection with C# under ASP.Net Core

一个人想着一个人 提交于 2019-12-20 02:32:34
问题 I am trying to connect my new Project (ASP.Net Core Framework) with Access Database . What do I need to enter into: appsettings.json -> "ConnectionStrings"? And do I have to install something for it? This framework is new and unfortunately I found no much on the Internet. I need to connect exactly "Access database". I would be very happy for detailed information. 回答1: From this link : https://blogs.msdn.microsoft.com/dotnet/2016/11/09/net-core-data-access/ What about OLE DB? OLE DB has been a

Accessing app.config in ASP.NET

北城以北 提交于 2019-12-20 01:08:52
问题 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=

How to update appsettings.json based on publish profile using .NET Core?

余生颓废 提交于 2019-12-19 17:45:40
问题 I'm currently making the switch from .NET Framework to .NET Core. In the past, all of my application settings were in the Web.config file. When I added a new publish profile, I could right click and select 'Add Config Transform' which would generate a nested Web.{Profile}.config file under Web.config where I could set application settings that were specific to the respective profile. Now, in .NET Core, I want to achieve the same effect using an appsettings.json file instead of Web.config file

Value cannot be null. Parameter name: connectionString appsettings.json in starter

拟墨画扇 提交于 2019-12-18 05:37:45
问题 I am trying to write my connection string in my appsettings.json file and bring it into my startup file but I keep getting a Value cannot be null. Parameter name: connectionString. I have been using various examples but can't seem to see this new setup with ASP.NET 1.0 Core startup class. Appsetting.json file: { "Data": { "DefaultConnection": { "ConnectionString": "Data Source=server;Initial Catalog=dbase;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes":

ASP.NET Web.config AppSettings Performance

孤街醉人 提交于 2019-12-18 04:44:11
问题 I have a number of appSettings in web.config that are used frequently (i.e. on each post back). Does the ConfigurationManager hold these values in process or are there any performance gains to be had by copying these values into application state on ApplicationStart() and subsequently retrieving them from there? 回答1: AFAIK the configuration is read and parsed at startup and the data is held in memory thereafter. I don't believe any performance gains from caching the state in application

NLog config file to get configuration setting values from a web.config

≯℡__Kan透↙ 提交于 2019-12-18 04:44:11
问题 Is there a method to get a value from the <ApplicationSettings> section of a web.config within NLog layout variables? I already store SMTP details within my web.config and don't want to duplicate the settings just to use within my NLog.config. Ideally I'd like to do something like: ${aspnet-config:SmtpHostServer} which then fetches the value from the web.config 回答1: I couldn't see any obvious way to do this other than creating my own LayoutRenderer (see below). If you're putting into your own