tonerdo / dotnet-env

A .NET library to load environment variables from .env files
MIT License
427 stars 50 forks source link

Not Able to read env variables for project type .NET Framework 4.7.2 #62

Closed raban33 closed 2 years ago

raban33 commented 2 years ago

I have created .env file in the root of the asp.net mvc application and is trying to load using below code

DotNetEnv.Env.Load(); var value = System.Environment.GetEnvironmentVariable("HELLO");

value is always Null. I tried using below code aswell but no luck. Are you sure this works with .NET Framework 4.6 + ?? DotNetEnv.Env.TraversePath().Load();

rogusdev commented 2 years ago

If it compiles, it works. Where is your .env file located relative to the executable you are running?

rogusdev commented 2 years ago

I will assume this is working now if I don't hear any updates in the next few days.