In my .Net Core project I am using the IConfiguration interface to handle some configuration.
Inside my classes it is used like this:
public MyClass(IConfiguration configuration)
{
var someValue = configuration.GetSection("Key").Value;
}
And everything works fine when I start the project.
The problem is when I start the program from another location, e.g. a Shortcut.
Then the IConfiguration tries so find the "appsettings.json" in the folder, where the shortcut is located.
Is there some way to configure the IConfiguration in a central place and define a constant folder where the settings should be searched for.
You can try using ConfigurationProvider/ConfigurationBuilder to either use environment variables for the settings or can specify the location of appsettings.json and use it.
https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration-providers https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.configuration.configurationbuilder
Maybe i should have digged deaper into my code, and I found an Extensions class that searches the app.settings quite dirty. Sorry to bother you, but thanks for your help!