I wan't get cpuid in a console app with core3.0 preview with
c#
String processorID = "";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"Select * FROM WIN32_Processor");
ManagementObjectCollection mObject = searcher.Get();
foreach (ManagementObject obj in mObject)
{
processorID = obj["ProcessorId"].ToString();
}
return processorID;
And exception throwed:Cannot marshal 'parameter dotnet/corefx#3': Cannot marshal a string by-value with the [Out] attribute.
I assume it is System.Management problem? @Anipik can you please help?
Yeah i will take a look
i tried it with the master branch as well core3.0 preview, i am not able to repro the bug.
Its the printing the processor id as BFEBFBFF000406F1
can you give more context on the failure or about the machine where you are running this code ?
It was throwed when new a ManagementObjectSearcher. The StackTrace :
at System.StubHelpers.StubHelpers.ThrowInteropParamException(Int32 resID, Int32 paramIdx)
at System.Management.ManagementPath.GetWbemPath(IWbemPath wbemPath)
at System.Management.ManagementPath.GetWbemPath()
at System.Management.ManagementPath.get_Path()
at System.Management.ManagementScope.set_prvpath(ManagementPath value)
at System.Management.ManagementScope._Clone(ManagementScope scope, IdentifierChangedEventHandler handler)
at System.Management.ManagementScope._Clone(ManagementScope scope)
at System.Management.ManagementObjectSearcher..ctor(ManagementScope scope, ObjectQuery query, EnumerationOptions options)
at System.Management.ManagementObjectSearcher..ctor(String queryString)
at CustomConfig.HwInfoService.GetMachineCode() in D:\TFlow_Clould\TfrcClould\CustomConfig\HwInfoService.cs:line 20
at CustomConfig.Config..cctor() in D:\TFlow_Clould\TfrcClould\CustomConfig\Config.cs:line 42
And Its the printing the processor id as BFEBFBFF000506E3 in a core 2.1 console app.
I guess it's related to calling unmanaged DLL.
@Anipik any update?
@zhusheping are you still able to reproduce on latest Preview of 3.0?
This is known issue with .NET Core 3.0 and old version of System.Management package.
For .NET Core 3.0, you need to reference latest preview version 4.6.0-preview5.19224.8 of https://www.nuget.org/packages/System.Management/ to workaround it.
cc @jkoritzinsky
This is duplicate of dotnet/runtime#29725 and dotnet/runtime#28840
Most helpful comment
This is known issue with .NET Core 3.0 and old version of System.Management package.
For .NET Core 3.0, you need to reference latest preview version 4.6.0-preview5.19224.8 of https://www.nuget.org/packages/System.Management/ to workaround it.
cc @jkoritzinsky
This is duplicate of dotnet/runtime#29725 and dotnet/runtime#28840