我需要在 powershell 脚本中使用我的 dotnet core 3 程序集之一:
try {
Add-Type -Path "app.dll"
}
catch {
$_.Exception.LoaderExceptions
}
Run Code Online (Sandbox Code Playgroud)
这失败了:
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.
Run Code Online (Sandbox Code Playgroud)
为什么我尝试Add-Type System.Private.CoreLib.lib,出现同样的错误。它似乎适用于 netstandard2.0 程序集,但不适用于我的 netcoreapp3.0 程序集。为了在 powershell 脚本中使用程序集的方法,我该怎么做?
小智 0
如果您需要加载面向 netstandard2.0 版本以上的 PowerShell .NET 程序集,那么您应该尝试在 PowerShell Core 7.1.3 或更高版本中执行脚本。
Windows PowerShell 可能只能加载面向 .NET Framework 或 netstandard2.0 的 .NET 程序集。
| 归档时间: |
|
| 查看次数: |
804 次 |
| 最近记录: |