Encrypt connection string in app.config

You can easily apply the same solution as the web.config you just have to rename your app.config to web.config, encrypt with the aspnet_regiis tool and then rename it back to app.config. Rename app.config to web.config Open command prompt and type: %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef “connectionStrings” c:\<folder containing your web.config> (stop at folder level and don’t put the … Read more

Why is a “bindingRedirect” added to the app.config file after adding the Microsoft.Bcl.Async package?

The assemblies Microsoft.Threading.Tasks and Microsoft.Threading.Tasks.Extensions are still referencing v1.5.11.0 of System.Runtime and System.Threading.Tasks. Without the bindingRedirect, the Microsoft.* assemblies would try to load an old version of the System.* assemblies, which would fail.

Can a class library have an App.config file?

No, class libraries can hold setting files, but their values will be defined in the application configuration (web.config, app.config…). That’s because of configuration settings overriding feature. You’ll need to declare the assemblies’ configuration sections in the app.config or web.config of your application (WPF, SL, ASP.NET…) and define a value for a particular number of settings … Read more

Actually read AppSettings in ConfigureServices phase in ASP.NET Core

That is the way you can get the typed settings from appSettings.json right in ConfigureServices method: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.Configure<MySettings>(Configuration.GetSection(nameof(MySettings))); services.AddSingleton(Configuration); // … var settings = Configuration.GetSection(nameof(MySettings)).Get<MySettings>(); int maxNumberOfSomething = settings.MaxNumberOfSomething; // … } // … Read more

How do you use sections in c# 4.0 app.config?

<configSections> <section name=”FBI” type=”System.Configuration.NameValueSectionHandler” /> <section name=”FSCS” type=”System.Configuration.NameValueSectionHandler” /> </configSections> <FSCS> <add key=”processingDirectory” value=”C:\testfiles\ProccesFolder”/> </FSCS> <FBI> <add key=”processingDirectory” value=”C:\testfiles\ProccesFolder”/> </FBI> And then: var section = ConfigurationManager.GetSection(“FSCS”) as NameValueCollection; var value = section[“processingDirectory”];

Do binding redirects in app.config for class libraries do anything?

I have multiple applications with similar setup – Web application referencing multiple library projects each having their own nuget packages etc., Based on my personal experience the assembly bindings in the library projects are not considered during run time. The bindings specified web or app config in the root application (web/console) is that only matters. … Read more

Can’t read app.config in C# .NET Core unit test project with ConfigurationManager

Looking through the github issue’s comments, I found a work around that can go in the msbuild file… <Target Name=”CopyCustomContent” AfterTargets=”AfterBuild”> <Copy SourceFiles=”app.config” DestinationFiles=”$(OutDir)\testhost.dll.config” /> </Target> This makes it easier to verify existing tests under .NET Core before porting the configuration data over to json configuration files. Edit If running under Resharper, the previous answer … Read more

How to make spring inject value into a static field

You have two possibilities: non-static setter for static property/field; using org.springframework.beans.factory.config.MethodInvokingFactoryBean to invoke a static setter. In the first option you have a bean with a regular setter but instead setting an instance property you set the static property/field. public void setTheProperty(Object value) { foo.bar.Class.STATIC_VALUE = value; } but in order to do this you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)