C
C#•2w ago
Doppelbemme

WPF .NET 8.0 cant find System.Management Reference

Hey folks, I just recently got into C# and want to create a Desktop app to get comfortable with it. I created a WPF Project with .NET 8.0 as the Target Framework and wanted to get the name of the user's mainboard. I used this piece of logic, which requires the ManagementObject, which requires me to use the System.Management namespace
c#
public static String getMotherboardName()
{
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
foreach (var item in searcher.Get())
{
return item["Product"].ToString();
}
return "Unknown Motherboard";
}
c#
public static String getMotherboardName()
{
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
foreach (var item in searcher.Get())
{
return item["Product"].ToString();
}
return "Unknown Motherboard";
}
I tried to add said reference but I cant find it in the Reference Manager.
No description
38 Replies
Doppelbemme
DoppelbemmeOP•2w ago
Here are my General Application Settings, if thats important to resolve the issue 😄
No description
Buddy
Buddy•2w ago
Why do you want motherboard name?
Doppelbemme
DoppelbemmeOP•2w ago
We have a server which stores mainboard names and hardware ids and there respective driver packages that need to be installed at deployment. So I need a way to access the systems mainboard name
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
In order to get the name of the mainboard so we can store it on our server with the drivers that we selected
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Oh yeah sorry my bad. Didnt explained that. The people in our production take the laptops and pc´s that have been freshly build and then start the counter part software. It checks there hardware id or the mainboard name against our server and then downloads the specified drivers onto that system. That tool is used completly inhouse and only by our production people. I used to do web apps before but the old software we used decided to lag and crash all the time so we need a new one. And my colleague that did c# before left recently so I cant ask him anymore :p
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
I will certainly keep that in mind thanks. That would have probably caused headaches down the road :p
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
I´m sorry, what does AD joined means?
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Ah my bad. No they connect to a share and download the stuff from there
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Customers. We just build them, set them up with drivers and a windows key and ship them
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Exactly. External people
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
I really would love to rework that entire system but sadly I cant at the moment. Hopefully we can do that sometime in the future though
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
But to get back to the original problem. Do you know why I cant add the System.Management Reference?
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Oh do I need to select something different when creating the project?
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
The only error I´m getting is this one when I try to run it
The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?)
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
No I didnt. Thats my main problem at this point I cant add it
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Thats my problem at the moment
No description
Doppelbemme
DoppelbemmeOP•2w ago
I cant find it. I havent got an error, since I cant even add it
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
I wish we had one 😶
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Sure thing
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>

</Project>
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
My god Im an idiot I´m so sorry I tried getting it with nuget to, but I wasnt showing up. I just realised, that nuget.org wasnt set up as a package source
Unknown User
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Doppelbemme
DoppelbemmeOP•2w ago
Wont be on the customer pc at the time of shipping it. No worrys. We delete all of our software and then do a sysprep. I will keep this as my c# learning project and message someone later. Either they need to live with the current piece of software lagging or they need to speed up there hiring process for a new person that knows c# Again I´m more then thankful for your help. I should have been able to figure that out myself. I thought that visual studio would setup the package sources for me...

Did you find this page helpful?