(NetNative)中的NotImplementedException NetworkInterface.GetNetworkInterfaces()Win IoT Core 14393

时间:2018-05-29 03:26:09

标签: c# windows-10-iot-core azure-iot-hub windows-iot-core-10

我试图在使用DotNetty和Windows的IoT Core上运行一些代码 我遇到了以下异常:

System.TypeInitializationException: The type initializer for 'DotNetty.Transport.Channels.DefaultChannelId' threw an exception. ---> System.NotImplementedException: The method or operation is not implemented. at System.Net.NetworkInformation.NetNativeNetworkInterface.GetNetworkInterfaces() at DotNetty.Common.Internal.MacAddressUtil.GetBestAvailableMac() at DotNetty.Common.Internal.DefaultPlatform.DotNetty.Common.Internal.IPlatform.GetDefaultDeviceId() at DotNetty.Transport.Channels.DefaultChannelId.DefaultMachineId() at DotNetty.Transport.Channels.DefaultChannelId..cctor() --- End of inner exception stack trace --- at DotNetty.Transport.Channels.AbstractChannel.NewId() at DotNetty.Transport.Channels.AbstractChannel..ctor(IChannel parent) at DotNetty.Transport.Channels.Sockets.AbstractSocketChannel..ctor(IChannel parent, Socket socket)

我在github上发现corefx 9675的问题,其中一条评论说

  

这些特定方法现在尚未实现。我们计划在今年晚些时候在System.Net.NetworkInformation软件包的更新中添加其余的支持。

我打电话给System.Net.NetworkInformation包v4.3.0 System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()我很遗憾地得到NotImplementedException例外。

`System.NotImplementedException: The method or operation is not implemented. at System.Net.NetworkInformation.NetNativeNetworkInterface.GetNetworkInterfaces() at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()

问题

我可以在Windows IoT Core 14393上完成这项工作吗?

1 个答案:

答案 0 :(得分:2)

如果您使用UWP,则需要10.0.16299。

因为此API(System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())适用于.NET Standard 2.0且最低版本支持.NET Standard 2.0为16299.此外,您需要设置 UWP app min目标版本至16299

enter image description here

参考:.NET implementation support

否则,您可以使用.NET Core Console应用程序或.NET Framework Console应用程序,但可以选择更多版本:

enter image description here

参考:NetworkInterface.GetAllNetworkInterfaces Method