Skip to content

System.Management.WbemDefPath doesn't work with trimming #61960

@Symbai

Description

@Symbai

Description

NativeAOT (the trimming?) breaks the body of System.Management.WbemDefPath..ctor():

 ---> System.InvalidProgramException: Common Language Runtime detected an invalid program. The body of method 'Void System.Management.WbemDefPath..ctor()' is invalid.
   at Internal.Runtime.TypeLoaderExceptionHelper.CreateInvalidProgramException(ExceptionStringID, String) + 0x40
   at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowInvalidProgramExceptionWithArgument(ExceptionStringID, String) + 0x9
   at System.Management.WbemDefPath..ctor() + 0x15

I'm reporting this here since NativeAOT will be moved into this repo anyway and it's probably a trimming issue? in which case it belongs to this repo.

Reproduction Steps

In nativeAOT project:

ManagementClass managementClass = new ManagementClass("Win32_BaseBoard");
var instances = managementClass.GetInstances();
foreach (var obj in instances)
{
    //...
}

In C# project call the export function of the nativeAOT project which executes the code above.

Expected behavior

No exception

Actual behavior

Exception

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

It's a windows x64 DLL project publishing using /p:NativeLib=Shared, I'm using NativeAOT compiler nuget version 6.0.0-*

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions