System.Management.ManagementObjectSearcher works from visual studio console app but not from Unity

I have a visual studi console app that searches for data about serial ports, and it works great every time. Even if I build the project as a class library (.dll) I can use it in other visual studio projects. But when I try to run it in Unity: System.Management.ManagementObjectSearcher returns null.

My .net project target framework is 3.5 which is as high unity will allow. My unity api compatibility level is .net 2.o. I have a using System.Management; reference and the System.Management.dll is from unity\Editor\Data\Mono\lib\mono\2.0 folder. Any sugestions. I really need this to work.

Here is a test Method:(it returns bad language when not working)

public string TestFindPorts()
    {//@testing
        try
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM  Win32_PnPEntity");
            List<ManagementObject> objects = new List<ManagementObject>();
            foreach (ManagementObject obj in searcher.Get())
            {
                objects.Add(obj);
            }
            return "found some----------------+++++++--------";
        }
        catch (Exception e)
        {
            //Console.WriteLine("root\\CIMV2 returned no usable results, bluetooth/serial port info is inaccsessible on this computer: " + e);
            return "crap idiot code---------------++++++--------";
        }
    }

Do you have the “System.Management.dll” copied into your project? Keep in mind that Unity does not rely on an installed .NET framework. You can’t reference “external” assemblies. Any assembly that you use has to be shipped with your game. In fact it’s shipped with the whole mono CLI but that doesn’t automatically include all possible class libraries. Also keep in mind that this ManagementObjectSearcher class seems to be a COM object wrapper. So it will most likely only work on windows builds if it actually is compatible with Mono.