When I deploy to server my app seems unable to read from the appsettings.json file.
I have this code in my configure method:
var connectionStringPath = "production:pgConString";
if (Env.IsDevelopment())
{
connectionStringPath = "development:pgConString";
}
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
AppSettings.Get<string>(connectionStringPath),
PostgreSqlDialect.Provider));
container.Register<IAuthRepository>(c =>
new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));
container.Resolve<IAuthRepository>().InitSchema();
This works fine locally but it seems that on the server (Ubuntu 18.04) there is an empty string passed and it generates the exception Host Cant Be Null
. I replaced the call to the settings file with a hard coded string and the app runs fine but I would much rather use config file.
To try to get some more info on what is going on I followed: https://github.com/Microsoft/MIEngine/wiki/Offroad-Debugging-of-.NET-Core-on-Linux---OSX-from-Visual-Studio
However this doesn’t hit any break points or show locals. It just gives the exception name and says:
No compatible code running
The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).
Do you have any idea why it is not reading from the appsettings.json file on server or why I am unable to remote debug it with the offroad debugging method?