question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Could not load file or assembly Microsoft.Management.Infrastructure

See original GitHub issue

DeviceId: 5.3.0 Running the app on windows 10 I have the following error:

 Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at DeviceId.Internal.Wmi.GetValues(String className, String propertyName)
   at DeviceId.Components.WmiDeviceIdComponent.GetValue()
   at DeviceId.Formatters.HashDeviceIdFormatter.<>c.<GetDeviceId>b__3_1(IDeviceIdComponent x)
   at System.Linq.Enumerable.SelectIPartitionIterator`2.PreallocatingToArray(Int32 count)
   at System.Linq.Enumerable.SelectIPartitionIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at DeviceId.Formatters.HashDeviceIdFormatter.GetDeviceId(IEnumerable`1 components)
   at DeviceId.DeviceIdBuilder.ToString()

My code looks like this:

var systemId = new DeviceIdBuilder()
                .AddProcessorId()
                .AddMotherboardSerialNumber()
                .AddSystemUUID()
                .AddOSInstallationID()
                .UseFormatter(new HashDeviceIdFormatter(() => MD5.Create(), new Base64UrlByteArrayEncoder()))
                .ToString();

Is it a bug or am I doing something wrong? Appreciate any help.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fairkingcommented, Aug 19, 2021

Ok, I switched to v6.0 and the following example is working on Windows (runtime win-x64) 👍

            string systemId = new DeviceIdBuilder()
                .AddMacAddress()
                .AddOsVersion()
                .OnWindows(windows => windows
                    .AddProcessorId()
                    .AddMotherboardSerialNumber()
                    .AddSystemUuid())
                .OnLinux(linux => linux
                    .AddCpuInfo()
                    .AddMotherboardSerialNumber()
                    .AddProductUuid())
                .UseFormatter(new HashDeviceIdFormatter(() => MD5.Create(), new Base64UrlByteArrayEncoder()))
                .ToString();

Thanks a lot for your help. 🥇

0reactions
MatthewKingcommented, Aug 19, 2021

Glad you got it going!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running Powershell from .Net Core - Could not load file or ...
Problem is probably caused by the fact, that under C:\Users\UserName\.nuget\packages\microsoft.management.infrastructure\1.0.0\runtimes there ...
Read more >
Import-Module : Could not load file or assembly 'System. ...
I'm unable to run PnP PowerShell commands using PowerShell ISE in administrative mode. Getting following error PS C:\WINDOWS\system32> ...
Read more >
System.IO.FileNotFoundException: Could not load file or ...
But when i deploy to IIS in production i keep getting: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.
Read more >
Could not load file or assembly 'Microsoft.Management ...
I did some research and figured the following: Answer 1: There is no Runtime identifer specific Microsoft.Management.Infrastructure.dll files in the ...
Read more >
Missing assemblies in publish output
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found