0

My vb.net app is using .net framework 4.6
I replaced System.IO.Ports with System.IO.Ports.Mono (for netstandard 2.0) from https://github.com/michaldobrodenka/System.IO.Ports.Mono

Then the app is crashing when calling GetPortNames at loading :
System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'Microsoft.Win32.Registry, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Source=System.IO.Ports.Mono StackTrace: at System.IO.PortsPlus.SerialPort.GetPortNames() in C:\dotnet2019\SpectroSaveVb\System.IO.Ports.Mono-master\System.IO.PortsPlus\SerialPort.cs:line 563 at System.IO.PortsPlus.SerialPort.GetDefaultPortName() in C:\dotnet2019\SpectroSaveVb\System.IO.Ports.Mono-master\System.IO.PortsPlus\SerialPort.cs:line 103 at System.IO.PortsPlus.SerialPort..ctor() in C:\dotnet2019\SpectroSaveVb\System.IO.Ports.Mono-master\System.IO.PortsPlus\SerialPort.cs:line 63 at System.IO.PortsPlus.SerialPort..ctor(IContainer container) in C:\dotnet2019\SpectroSaveVb\System.IO.Ports.Mono-master\System.IO.PortsPlus\SerialPort.cs:line 67 at SpectroSave.SpectroSave.InitializeComponent() in C:\dotnet2019\SpectroSaveVb\SpectroSave.Designer.vb:line 58 at SpectroSave.SpectroSave..ctor() in C:\dotnet2019\SpectroSaveVb\SpectroSave.vb:line 36

  • 1
    From the answer to [.NET Framework 4.6.2 and .NET Standard 2.0 incompatibility](https://stackoverflow.com/a/46583252/1115360), "As of the latest tooling updates in VS 2017 15.3 and .NET Core 2.0.0 SDK (released in August 2017), the minimum version of .NET Framework that supports .NET Standard 2.0 is 4.6.1." So, is there any chance you could update the project to use .NET Framework 4.8 to get through any problems in one go? – Andrew Morton Jun 01 '22 at 22:47
  • I've already tried to update to .NET Framework 4.7.2 but it doesn't fix the issue. I can't undestand why it is crashing when calling this GetPortNames which code is in the System.IO.PortsPlus.SerialPort class ! This code is in my project ! And also it was able to call first GetDefaultPortName from this same class : static string GetDefaultPortName () { string[] ports = GetPortNames(); .... – Moshe B Jun 02 '22 at 13:59
  • Does [Error: Could not load file or assembly 'Microsoft.Win32Registry' from .NET Standard Library Consumed by .NET Framework Console App](https://stackoverflow.com/q/57318034/1115360) help? – Andrew Morton Jun 02 '22 at 19:53
  • 1
    Thanks Andrew, this has fixed the issue : [Error: Could not load file or assembly 'Microsoft.Win32Registry' from .NET Standard Library Consumed by .NET Framework Console App](https://stackoverflow.com/questions/57318034/error-could-not-load-file-or-assembly-microsoft-win32registry-from-net-stand) – Moshe B Jun 06 '22 at 09:27

0 Answers0