0

Trying to host my webapi on the production machine but there, all DI services remains null. And I get the NullReferenceException everywhere I try to access the services variable inside the Startup class.

The exception points the line where I'm adding the context. services.AddDbContext(x=>x.UseMySql(...)). If I remove this line, then It jumps to the services.AddAutoMapper() and so on.

Note that this occurs only on the production machine. Everything is pretty cool on my dev machine.

Am I missing a config file (appsetting.json and appsetting.dev.json are both identicall) OR is there another cause?

Bellash
  • 7,560
  • 6
  • 53
  • 86

1 Answers1

0

Really had hard time solving this issue! I had to navigate to the folder and run dotnet myApi.dll instead of using the path dotnet /var/apps/myapi/myApi.dll.

Not sure but It seems like the cli is looking for a config file in the directory from within it's being called

Bellash
  • 7,560
  • 6
  • 53
  • 86