-
Notifications
You must be signed in to change notification settings - Fork 126
Description
Hello,
we use DeviceId in docker. It works in a Linux container, but not in a Windows container.
You support AddDockerContainerId for DeviceId.Linux in the README file. Do you also support Windows containers?
I found the problem where it fails is on this line:
DeviceId/src/DeviceId.Windows.Wmi/Components/WmiSystemDriveSerialNumberDeviceIdComponent.cs
Line 23 in 6be01e1
| var systemLogicalDiskDeviceId = Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 2); |
Environment.SpecialFolder.System returns "System"
Environment.GetFolderPath(Environment.SpecialFolder.System) returns an empty string so Substring(0, 2) fails.
Failure with this code:
string deviceId = new DeviceIdBuilder()
.OnWindows(windows => windows
.AddProcessorId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber()
.AddSystemUuid())
.OnLinux(linux => linux
.AddCpuInfo()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber()
.AddMachineId())
.AddFileToken(TokenFilePath)
.AddMachineName()
.ToString();
Stack Trace:
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length) in /_/src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs:line 1878\r\n
at System.String.Substring(Int32 startIndex, Int32 length) in /_/src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs:line 1852\r\n
at DeviceId.Windows.Wmi.Components.WmiSystemDriveSerialNumberDeviceIdComponent.GetValue() in /_/src/DeviceId.Windows.Wmi/Components/WmiSystemDriveSerialNumberDeviceIdComponent.cs:line 23\r\n
at DeviceId.Formatters.HashDeviceIdFormatter.<>c.<GetDeviceId>b__3_1(KeyValuePair`2 x) in /_/src/DeviceId/Formatters/HashDeviceIdFormatter.cs:line 47\r\n
at System.Linq.Enumerable.SelectIPartitionIterator`2.PreallocatingToArray(Int32 count) in /_/src/libraries/System.Linq/src/System/Linq/Select.SpeedOpt.cs:line 606\r\n
at System.Linq.Enumerable.SelectIPartitionIterator`2.ToArray() in /_/src/libraries/System.Linq/src/System/Linq/Select.SpeedOpt.cs:line 620\r\n
at DeviceId.Formatters.HashDeviceIdFormatter.GetDeviceId(IDictionary`2 components) in /_/src/DeviceId/Formatters/HashDeviceIdFormatter.cs:line 47\r\n
at DeviceId.DeviceIdBuilder.ToString() in /_/src/DeviceId/DeviceIdBuilder.cs:line 54\r\n
Probably the same problem here:
DeviceId/src/DeviceId.Windows.Mmi/Components/MmiSystemDriveSerialNumberDeviceIdComponent.cs
Line 22 in 9c81245
| var systemLogicalDiskDeviceId = Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 2); |
Thank you in advance for your feedback.