首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用netcoreapp3.0程序集的PowerShell :添加类型失败,并显示“无法从程序集‘System.Private.CoreLib’加载类型'System.Object‘”

使用netcoreapp3.0程序集的PowerShell :添加类型失败,并显示“无法从程序集‘System.Private.CoreLib’加载类型'System.Object‘”
EN

Stack Overflow用户
提问于 2019-10-15 16:41:08
回答 1查看 490关注 0票数 4

我需要在powershell脚本中使用我的dotnet core 3程序集之一:

代码语言:javascript
复制
try { 
    Add-Type -Path "app.dll" 
}
catch { 
    $_.Exception.LoaderExceptions 
}

这将失败:

代码语言:javascript
复制
Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does 
not exist.

为什么我尝试添加类型的System.Private.CoreLib.lib,同样的错误也发生了。它似乎可以很好地用于netstandard2.0程序集,但不能用于我的netcoreapp3.0程序集。要在powershell脚本中使用程序集的方法,我应该做些什么?

EN

回答 1

Stack Overflow用户

发布于 2021-08-08 22:39:10

如果您需要在PowerShell .NET程序集中加载netstandard2.0以上的版本,那么您应该尝试在PowerShell Core7.1.3或更高版本中执行您的脚本。

Windows PowerShell可能只能加载面向.NET框架或netstandard2.0的.NET程序集。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58390560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档