问题
我正在尝试创建一个使用 SimpleInjector 的 PowerShell Core 二进制 cmdlet 库,但无法弄清楚为什么在FileNotFoundException
使用 Visual Studio 对其进行调试时会导致错误。
细节
我在 Visual Studio 中创建了一个超级简单的 PowerShell cmdlet 库,面向 .NET Standard 2.0 并使用PowerShellStandard.Library
包 (v5.1.0-RC1)。您可以在此处查看/克隆它。它包含以下 cmdlet:
using System.Management.Automation;
using Newtonsoft.Json.Linq;
using SimpleInjector;
[Cmdlet(VerbsDiagnostic.Test, "SimpleInjectorDependency")]
public class TestSimpleInjectorDependencyCmdlet : PSCmdlet
{
protected override void ProcessRecord()
{
var container = new Container();
WriteObject("Success!");
}
}
结果是FileNotFoundException
:
这似乎是 SimpleInjector 特有的,因为使用例如 json.net 执行相同的操作没有问题:
using System.Management.Automation;
using Newtonsoft.Json.Linq;
using SimpleInjector;
[Cmdlet(VerbsDiagnostic.Test, "JsonDotNetDependency")]
public class TestJsonDotNetDependencyCmdlet : PSCmdlet
{
protected override void ProcessRecord()
{
var j = new JObject();
WriteObject("Success!");
}
}
我真的不明白这里发生了什么。我什至不确定这是否真的特定于 SimpleInjector,或者是否还有其他因素在起作用。如果有人能启发我,我将不胜感激!