Visual Studio 2022 和 Net6 中的 Hostpolicy.dll 问题

问题描述 投票:0回答:1

我下载了 Visual studio 2022 Final 和 Net6,但是当我创建一个最开始的控制台应用程序时,它构建正常,但是在调试或不调试时它会抛出异常:说:

    A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet\'.
    Failed to run as a self-contained app.
      - The application was run as a self-contained app because 'C:\Users\<UserName>\source\repos\ConsoleApp2022\ConsoleApp2022\bin\Debug\net6.0\ConsoleApp2022.runtimeconfig.json' was not found.

  - If this should be a framework-dependent app, add the 'C:\Users\<UserName>\source\repos\ConsoleApp2022\ConsoleApp2022\bin\Debug\net6.0\ConsoleApp2022.runtimeconfig.json' file and specify the appropriate framework.

请任何人为我提供解决此问题的指导。

注意:我做了很多搜索但没有找到任何解决方案,并且解决方案是针对以前的net core

c# exception console .net-6.0 visual-studio-2022
1个回答
0
投票

尝试添加一些命令行选项,例如:

--runtimeconfig .\ConsoleApp2022.runtimeconfig.json  
--depsfile .\ConsoleApp2022.deps.json
© www.soinside.com 2019 - 2024. All rights reserved.