locked
.Net Core 2.2 deployed app's web.config variables are null RRS feed

  • Question

  • User297458589 posted

    I have recently deployed my web app to IIS. However, I can't even run it. When I do a dotnet SDR_Administrator.Web.dll, this error appears:

    Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: path at System.IO.Directory.CreateDirectory(String path) at SDR_Administrator.Web.Startup.ConfigureServices(IServiceCollection service s) in D:\a\1\s\SDR_Administrator.Web\Startup.cs:line 48 --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(ISer viceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at SDR_Administrator.Web.Program.BuildWebHost(String[] args) in D:\a\1\s\SDR_ Administrator.Web\Program.cs:line 43 at SDR_Administrator.Web.Program.Main(String[] args) in D:\a\1\s\SDR_Administ rator.Web\Program.cs:line 27

    The lines 48 in the Startup.cs is this line:

    var keyringPath = Environment.GetEnvironmentVariable(SDR_Core.Web.ClassLibrary.Globals.ConfigurationGlobals.KeyStorage);
    System.IO.Directory.CreateDirectory(keyringPath);
    

    When I finish my deployment, I can see that the web.config file is populated correctly with all the required variables with this as an example:

    <environmentVariable name="STORAGE" value="C:\Data" />
    

    I'm stuck on this section. What else am I missing?

    Saturday, March 6, 2021 7:17 AM

All replies

  • User1686398519 posted

    Hi StardocsSVC, 

    StardocsSVC

    Value cannot be null. Parameter name: path at System.IO.Directory.CreateDirectory(String path)

    According to the error message you gave, I think the value of keyringPath is null.

    StardocsSVC

    SDR_Core.Web.ClassLibrary.Globals.ConfigurationGlobals.KeyStorage

    Does the value of "SDR_Core.Web.ClassLibrary.Globals.ConfigurationGlobals.KeyStorage" already exist?

    If the environment variable(from the current process or from the Windows operating system registry key for the current user or local machine)does not exist, then the value you get using Environment.GetEnvironmentVariable is empty.

    You can click this link to learn about setting the environment.

    Best Regards,

    YihuiSun

    Monday, March 8, 2021 5:42 AM