appsettings

Referenced assembly can not read app.config

这一生的挚爱 提交于 2019-12-25 05:07:28
问题 I'm having problems with my unit tests. The problem is: I'm using Sitecore. Another question I asked about this is: Unit Testing Sitecore LicenseManager My problem is that I get the exception: Test method foo.Bar.Framework.Tests.Core.UnitTest1.TestMethod1 threw exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Sitecore.Services.Heartbeat' threw an exception. --->

Referenced assembly can not read app.config

↘锁芯ラ 提交于 2019-12-25 05:07:02
问题 I'm having problems with my unit tests. The problem is: I'm using Sitecore. Another question I asked about this is: Unit Testing Sitecore LicenseManager My problem is that I get the exception: Test method foo.Bar.Framework.Tests.Core.UnitTest1.TestMethod1 threw exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Sitecore.Services.Heartbeat' threw an exception. --->

Problems retrieving appsettings added during application start

那年仲夏 提交于 2019-12-25 01:46:18
问题 I appear to be having an odd issue where, in my global.asax in my Application_Start(), I have something that goes off to my database, gets all of my app settings from a name/value table, and then drops them into the application via Application.Add(name,value) . I have an 'application facade' in another project which is used by my service layers, data layers and so on in order to get settings I need to do various bits and pieces. In my database, I have a couple of entries: ConfigName |

restart website in IIS when changing values in the appSettings of the web.config

回眸只為那壹抹淺笑 提交于 2019-12-24 02:09:45
问题 Just to be safe, when I make changes in the values of the appSettings in the Web.config I always restart the WebSite so all the changes can be refreshed. But do I really need to restart it? how is IIS handling the appSetting values, is it reading the values in one time (once you start the application) or is IIS reading it every time a client is accessing the website? 回答1: Actually, it is not the "Website" but the "App Pool" that needs the restart. Remember the website pipeline in IIS has no

How to update app settings key value pair dynamically on app.config file in c# winforms

扶醉桌前 提交于 2019-12-23 10:24:20
问题 How to update app settings key, value dynamically on app.config file in c# winforms. Key,value are listed below <appSettings> <add key="logPath" value="C:\EventLogs" /> <add key="isScreenCaptureMode" value="false" /> <add key="isStartOnSysStartUp" value="false" /> </appSettings> 回答1: Configuration configuration = ConfigurationManager. OpenExeConfiguration(Assembly.GetExecutingAssembly().Location); configuration.AppSettings.Settings["logPath"].Value = DateTime.Now.ToString("yyyy-MM-dd");

AppSettings from custom files

狂风中的少年 提交于 2019-12-23 10:20:05
问题 I am struggling with the configuration and setting classes in .NET 2.0 If the following is contaned in a file called app.config <config> <appSettings> <add key="Foo" value="Hello World!"/> </appSettings> </config> I know I can access the appSetting by // this returns "Hello World!" ConfigurationManager.AppSettings["Foo"] However if the file is called app1.config (or any other name) I cannot access the appSetting. As long as I understand, with ConfigurationManager.OpenExeConfiguration I should

ConfigurationManager.AppSettings - Returns Null

≡放荡痞女 提交于 2019-12-23 08:07:12
问题 Im trying to read settings from my app.config and im sure it was working before but now it returns a nullReferenceException. My code getting the settings is as follows: codeValueUtilRx = ConfigurationManager.AppSettings["CODEVALUE_UTIL_RX"].Split(';').ToList(); My app-congfig is as follows: <appSettings> <add key ="LOGFILELOCATION" value ="C:\\RuleEditor\\"/> <add key ="CODEVALUE_UTIL_RX" value="GCN;GRP;NDC;SPEC;TCC"/> </appSettings> I have a feeling its something seemingly obvious, I just

Access section 'applicationSettings' (not 'appSettings') in config file from setup

徘徊边缘 提交于 2019-12-22 18:44:09
问题 I am in the process of creating a setup for a web application we build. No I have a configuration file, which looks something like like this, which contains a section 'appSettings', and a section 'applicationSettings': <configuration> <appSettings> <add key="Password" value="dummy"/> <add key="Username" value="dummy"/> <add key="DB" value="dummy"/> <add key="DBServer" value="dummy"/> <add key="LogStoredProcedure" value="dummy"/> <add key="ErrorStoredProcedure" value="dummy"/> <add key=

Get appsettings.json values in service .net core

泄露秘密 提交于 2019-12-22 10:43:30
问题 I have appsettings.json file where I want to declare paths to files. "Paths": { "file": "C:/file.pdf" } I want to access this value in my service, I try it to do like this: public class ValueService: IValueService { IConfiguration Configuration { get; set; } public MapsService(IConfiguration configuration) { this.Configuration = configuration; } public string generateFile() { var path = Configuration["Paths:file"] ; } } however I get null values for var path Startup.cs file has appsettings

Values from linked appsettings.json file in dotnet core cannot be read

谁都会走 提交于 2019-12-22 09:48:08
问题 In an aspnetcore 2.0 project I'm trying to setup a single, shared appsettings.json file throughout my web application and several of my xunit test projects. First off, everything works fine when I add the appsettings.json "regularly" to my projects individually. However, when I attempt to add a single reference/linked file from a different path, the values aren't read out during runtime. To set this up, for each project I add the linked file to the .csproj: <ItemGroup> <Content Include="..