Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WmiNetUtilsHelper exception if PublishTrimmed is true #49

Closed
yangjieshao opened this issue Jun 30, 2023 · 3 comments
Closed

WmiNetUtilsHelper exception if PublishTrimmed is true #49

yangjieshao opened this issue Jun 30, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@yangjieshao
Copy link

yangjieshao commented Jun 30, 2023

Library version

11.1.0.0

OS & OS version

Windows 11 22H2

Describe the bug

The type initializer for 'System.Management.WmiNetUtilsHelper' threw an exception.
System.TypeInitializationException
System.Management
Boolean IsNoContextMTA()
   at System.Management.MTAHelper.IsNoContextMTA()
   at System.Management.MTAHelper.CreateInMTA(Type)
   at System.Management.ManagementPath.CreateWbemPath(String)
   at System.Management.ManagementPath..ctor(String path)
   at System.Management.ManagementScope..ctor(String path)
   at System.Management.ManagementObjectSearcher..ctor(String, String, EnumerationOptions)
   at Hardware.Info.Windows.HardwareInfoRetrieval.GetOs()
   at Hardware.Info.Windows.HardwareInfoRetrieval..ctor(Nullable`1 enumerationOptionsTimeout)
   at Hardware.Info.HardwareInfo..ctor(Boolean useAsteriskInWMI, Nullable`1 timeoutInWMI)

Publish setting:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>bin\Release\net7.0\publish\win-x64\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <_TargetId>Folder</_TargetId>
    <TargetFramework>net7.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishReadyToRun>true</PublishReadyToRun>
    <PublishTrimmed>true</PublishTrimmed>
  </PropertyGroup>
</Project>

if PublishTrimmed is true threw exception.
if PublishTrimmed is false , Program is ok

@Jinjinov
Copy link
Owner

Jinjinov commented Jul 4, 2023

Thank you for noticing this, I will look into it!

@Jinjinov
Copy link
Owner

Jinjinov commented Jul 7, 2023

@Jinjinov Jinjinov added the help wanted Extra attention is needed label Jul 8, 2023
@Jinjinov Jinjinov pinned this issue Jul 8, 2023
@Jinjinov
Copy link
Owner

Jinjinov commented Jul 8, 2023

Unfortunately I couldn't find a solution.

@Jinjinov Jinjinov closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2023
@Jinjinov Jinjinov changed the title System.Management.WmiNetUtilsHelper' threw an exception. WmiNetUtilsHelper throws an exception when PublishTrimmed is true Jul 8, 2023
@Jinjinov Jinjinov changed the title WmiNetUtilsHelper throws an exception when PublishTrimmed is true WmiNetUtilsHelper throws exception if PublishTrimmed is true Jul 8, 2023
@Jinjinov Jinjinov changed the title WmiNetUtilsHelper throws exception if PublishTrimmed is true WmiNetUtilsHelper exception if PublishTrimmed is true Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants