c# - 使用 .NetCore 3.1 运行修剪过的自包含单个可执行文件 - 无法加载文件或程序集“Microsoft.Management.Infrastructure
问题描述
我在以 .Net Core 3.1 作为目标框架的控制台应用程序中调用 PowerShell 脚本。当我在调试模式下运行解决方案时,PowerShell 命令工作正常,但是当我运行 Trimmed Self-Contained Single Executable 时,出现以下错误:
出现异常System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.Management.Infrastructure,版本=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”。该系统找不到指定的文件。文件名:System.Reflection.RuntimeAssembly.GetExportedTypes() 中 System.Reflection.Assembly.get_ExportedTypes() 中的“Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection 中的 .Runspaces.PSSnapInHelpers.GetAssemblyTypes(程序集程序集,字符串名称)(程序集程序集,字符串名称,PSSnapInInfo psSnapInInfo,PSModuleInfo moduleInfo,字符串 helpFile,Dictionary2& cmdlet,Dictionary2& 别名,Dictionary2&
我尝试通过 Nuget 添加Microsoft.Management.Infrastructure包,但仍然存在同样的问题。有趣的是正在寻找 1.0.0.0 版本,而我的项目中安装了 2.0.0.0。如果有人对如何进行有任何建议,将不胜感激!
解决方案
推荐阅读
- javascript - 如何在 package.json 中添加新脚本
- .htaccess - 限制对文件夹、子文件夹和文件的访问 - htaccess
- javascript - 动态改变 vue 组件中显示的变量样式
- python - 如何让 django 在开发中服务静态文件?
- python - 使用 python 抓取标题 url 时出现错误
- c# - ASP.Net Core,我的谷歌图表不会显示
- java - 正则表达式 - Java 中的多行
- javascript - 带有选项卡和复选框的 Wordpress 联系表格 7 表格
- ios - Amazon SES 不向 Gmail id 发送电子邮件?
- python - 表单不与自定义表单字段一起保存