Thanks for taking the time to look at my question.
I have been sharing a data access layer between my ASP.NET Core 3.1 web app and my .NET Core 3.1 Windows Forms backend app through a class library pattern.
This has been working fine up until I decided to transition the data access layer to be injected using dependency injection.
I have successfully setup the Windows Forms app to use dependency injection, however this version of Windows Forms doesn't use appsettings.json
and therefore doesn't use an IConfiguration
instance to pass the connection string. Instead I access the connection string through Settings.settings
in the solution dependencies like so:
Properties.Settings.Default.MyConnectionString
I have tried to build an IConfiguration
object to read from Properties.Settings.Default
but I can't seem to find a method to instantiate an IConfigurationSection
to populate ConnectionStrings
section in IConfiguration
so that the
GetConnectionString("MyConnectionString")
call will work.
So my question is: can I reconfigure the Windows Forms .NET Core app to use AppSettings.json
? Or is there a way to build an instance of IConfiguration
that can be populated by Properties.Settings.Default.MyConnectionString
? Or is there a much better way of handling this situation that I haven't considered?
Any help is good help at the moment.