skip to Main Content

I am trying to use a DLL file along with Visual Studio in C# but upon running the code snippet it returns the error message in the title. I have tried updating powershell, downloading Microsoft SDKs, and updating Visual Studio all of which allegedly should have fixed the problems according to other posts but none of them have helped fix the issue. Could the issue be with the DLL file or is there a way for me to further figure out the issue causing the error? Any help is appreciated. Thank you.code snippet

I have followed the directions in the supplied pdf insctructing me to download the necessary drivers for the camera I’m using which are confirmed to be working and am using the correct DLL file supplied by the company. When running the code snippet it should return a list of COM ports available on my laptop but instead returns the error "System.IO.FileNotFoundException: Could not load file or assembly ‘System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. The system cannot find the file specified.
File name: ‘System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’
at NixLibrary.SerialPortTools.SerialPortPopulate()
at Program.$(String[] args) in C:UsersthebesourcereposNixAutomationNixAutomationProgram.cs:line 15"

2

Answers


  1. Chosen as BEST ANSWER

    "'It is a typical .NET5+ error. .NETCore has some backwards compatibility but not for System.Management. Migrate the project that has this reference, use the nuget package' – Hans Passant"


  2. Use the System.IO.Ports namespace.

     string[] AvailablePorts = SerialPort.GetPortNames();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search