Error using System.Management WMI calls

Hi, I'm using LINQPad 6.15 64-bit, trying to use System.Management in a query. I've referenced the assembly from C:\Windows\Microsoft.NET\Framework64\v4.0.30319

When I run the query, I get a MarshalDirectiveException "Cannot marshal 'parameter #3': Cannot marshal a string by-value with the [Out] attribute" while trying to create a new ManagementObjectSearcher. The same exception is thrown for any management classes I try to use.

Any suggestions would be appreciated.


  • Options
    edited December 2021

    Solved my own problem. Instead of referencing the local .NET Framework copy of System.Management, I've tried the nuget 6.0 package and that works fine in LINQPad6

    Probably daft on my part in hindsight, but I hope this helps others

Sign In or Register to comment.