Interacting with WMI via .NET core
Asked Answered
H

1

15

I need to get information about system such as: motherboard info, hdd info, e.t.c. in OS Windows. I can get it from wmi service. But I need to gather it with .NET core application.

I know in .NET application there interface IWbemServices to interact with WMI service, but I can't find something similar in .NET core.

So I have a questions:

  • Can I create COM object with .NET core application. If it's "yes" then how can I do it?
  • Are there other ways to get information about hardware, through .NET core?
Haplo answered 26/12, 2016 at 11:33 Comment(8)
Why do you want to interact with COM and WMI from a .NET Core application? .NET Core is cross-platform, but COM/WMI are Windows-specific. Maybe it would make sense to build a .NET Framework project instead?Hepner
as I said, I need some hardware information, such as Motherboard, cpu or RAM information. And it should be .net core app.Haplo
A .NET Core app that only runs on Windows?Hepner
for Linux there is other solution.Haplo
@Nate Barbettini net core compiled for net461 is very common eg use Asp.Net Core ( and its modern libs) but have a win32 dependency - Service fabric , Event Store etc etcAmericium
@NateBarbettini .Net Core has quite a few performance enhancements over the more robust .Net Framework. An ASP.Net Core application can run with much better performance. Not to mention some of the language goodies.Sacculus
did you try Nuget package nuget.org/packages/System.Management ?Meanly
WMI in Linux ? COM/WMI are Windows-specific.It is only for Windows, NetCore 3.1 with WMI (Management) doesnt' work in Linux.Meanly
C
5

The query is now available in Windows Compatibility Pack under System.Management.

Cumae answered 15/12, 2018 at 11:36 Comment(3)
Unfortunately this does not actually work with SCD in Dot Net Core. System.Management is dependent on COM interop which there is no near future solution to. github.com/dotnet/corert/issues/6728Dewberry
What's about nuget.org/packages/System.Management. ?Meanly
I'm getting an "EventLog access is not supported on this platform" error when I add the Windows Compatibility pack to my .Net Core app.Downright

© 2022 - 2024 — McMap. All rights reserved.