我有一个 .NET 标准库,如下所示:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace process_library
{
public class ProcessHandler
{
public ProcessHandler()
{
}
[MTAThread]
public Process[] GetProcesses()
{
return Process.GetProcesses();
}
}
}
然后我有一个 Template10 项目,其中所有 .net 核心内容都更新到了最新版本(构建它所必需的)并引用了我的库。到目前为止,这一切都有效。
在我的主视图模型中,我实例化了我的库类
ProcessHandler p = new ProcessHandler();
这也是成功的。
我的问题是,当我调用我的 get 进程方法时,它会吐出并抛出错误 GenericParameterAttributes = '((System.RuntimeType)type).GenericParameterAttributes' throwed an exception of type 'System.InvalidOperationException'
有什么办法可以让它工作吗?
更新删除了所有 Template10 的东西,因为它倾向于掩盖真正的错误并尝试了一个空白的 UWP 应用程序。获取此异常
System.PlatformNotSupportedException
HResult=0x80131539
Message=Retrieving information about local processes is not supported on this platform.
如果您甚至无法使用它,将其包含在 .net 标准中(应该包含您可以使用的标准 API 集)有什么意义
我还应该注意我的目标是最新的更新(2018 年春季)