I am having issues with the FindDeviceFromGuid(System.Guid myGuid, ref String[] devicePathName) function. I have the code part of my project, and when I compile it till .Net framework 4.0 it runs fine. However, for Framework 4.5 and higher (and only on Windows versions higher than 7), the code fails at the following section
success = SetupDiGetDeviceInterfaceDetail
(deviceInfoSet,
ref MyDeviceInterfaceData,
detailDataBuffer,
bufferSize,
ref bufferSize,
IntPtr.Zero);
// Skip over cbsize (4 bytes) to get the address of the devicePathName.
IntPtr pDevicePathName = new IntPtr(detailDataBuffer.ToInt32() + 4); <===== This is where it fails
// Get the String containing the devicePathName.
devicePathName[memberIndex] = Marshal.PtrToStringAuto(pDevicePathName);
with the error message
{"Arithmetic operation resulted in an overflow."}
Has anyone seen this issue before?