Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 发生未处理的异常:找不到包';的编译库位置;Microsoft.Win32.Registry';_C#_Docker_Exception_Asp.net Core Mvc - Fatal编程技术网

C# 发生未处理的异常:找不到包';的编译库位置;Microsoft.Win32.Registry';

C# 发生未处理的异常:找不到包';的编译库位置;Microsoft.Win32.Registry';,c#,docker,exception,asp.net-core-mvc,C#,Docker,Exception,Asp.net Core Mvc,当我为docker构建web项目并将其作为容器运行时,我使用的是asp.NETCore2.0,抛出的异常如下所示;但在本地运行时没有任何问题 我基本上做到了,在那之前,docker建造 网络还原 网络构建 网络出版 失败: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0] 发生未处理的异常:找不到包“Microsoft.Win32.Registry”的编译库位置 System.InvalidOperationExcept

当我为docker构建web项目并将其作为容器运行时,我使用的是asp.NETCore2.0,抛出的异常如下所示;但在本地运行时没有任何问题

我基本上做到了,在那之前,docker建造

  • 网络还原
  • 网络构建
  • 网络出版
  • 失败: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0] 发生未处理的异常:找不到包“Microsoft.Win32.Registry”的编译库位置 System.InvalidOperationException:找不到编译库 包“Microsoft.Win32.Registry”的位置

    这是我的.csproj文件

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
        <TypeScriptToolsVersion>2.5</TypeScriptToolsVersion>
        <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
      <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
        <PreserveCompilationContext>true</PreserveCompilationContext>
      </PropertyGroup>
    
      <PropertyGroup>
        <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
        <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
        <!--<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>-->
      </PropertyGroup>
    
      <ItemGroup>
        <None Update="Dockerfile">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </None>
      </ItemGroup>
      <ItemGroup>
        <Content Update="appsettings.json" CopyToOutputDirectory="Always" />
      <Content Update="Views\**\*" CopyToOutputDirectory="Always" />
      </ItemGroup>
      <ItemGroup>
        <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
        <PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
        <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.1" />
      </ItemGroup>
      <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
        <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
      </ItemGroup>
      <ItemGroup Label="Embedded Resources">
        <EmbeddedResource Include="Views\**\*.cshtml" />
      </ItemGroup>
      <ItemGroup>
        <None Include="wwwroot\app.component.js" />
        <None Include="wwwroot\app.component.js.map" />
        <None Include="wwwroot\app.component.ts" />
        <None Include="wwwroot\app.module.js" />
        <None Include="wwwroot\app.module.js.map" />
        <None Include="wwwroot\app.module.ts" />
        <None Include="wwwroot\app.routing.js" />
        <None Include="wwwroot\app.routing.js.map" />
        <None Include="wwwroot\app.routing.ts" />
        <None Include="wwwroot\Components\Home.component.js" />
        <None Include="wwwroot\Components\Home.component.js.map" />
        <None Include="wwwroot\Components\Home.component.ts" />
        <None Include="wwwroot\Components\inzmotivation.component.html" />
        <None Include="wwwroot\Components\inzmotivation.component.ts" />
        <None Include="wwwroot\js\system.config.js" />
        <None Include="wwwroot\main.js" />
        <None Include="wwwroot\main.js.map" />
        <None Include="wwwroot\main.ts" />
        <None Include="wwwroot\Model\InzMotivation.ts" />
        <None Include="wwwroot\Service\inzmotivations.service.ts" />
        <None Include="wwwroot\shared\enum.ts" />
        <None Include="wwwroot\shared\global.js" />
        <None Include="wwwroot\shared\global.js.map" />
        <None Include="wwwroot\shared\global.ts" />
      </ItemGroup>
      <ItemGroup>
        <TypeScriptCompile Include="wwwroot\Components\inzmotivation.component.ts" />
        <TypeScriptCompile Include="wwwroot\Model\InzMotivation.ts" />
        <TypeScriptCompile Include="wwwroot\polyfills.ts" />
        <TypeScriptCompile Include="wwwroot\Service\inzmotivations.service.ts" />
      </ItemGroup>
      <ItemGroup>
        <Folder Include="k8config\" />
      </ItemGroup>
    </Project>
    
    Program.cs

    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }
    
        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>()
                .UseUrls("http://*:8181")
                .UseApplicationInsights()
                .Build();
    }
    
    公共类程序
    {
    公共静态void Main(字符串[]args)
    {
    BuildWebHost(args.Run();
    }
    公共静态IWebHost BuildWebHost(字符串[]args)=>
    WebHost.CreateDefaultBuilder(args)
    .UseContentRoot(目录.GetCurrentDirectory())
    .UseStartup()
    .useURL(“http://*:8181”)
    .UseApplicationInsights()
    .Build();
    }
    
    这似乎是一种回归:@Gusman非常感谢。你的网址很有用。此外,我还将dotnet core cli更新为2.2.0-preview1-007582,效果很好@bilalkorkmaz,当.NET应用程序不是通过CLI创建的,而是部署到服务器上时,应该怎么做?
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }
    
        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>()
                .UseUrls("http://*:8181")
                .UseApplicationInsights()
                .Build();
    }