none
AccessViolationException in PropVariant.cs (Sensor Diagnostic Tool) RRS feed

  • Question

  • When I build and run in debug mode the SensorDiagnostic Tool I get a AccessViolationException in PropVariant.cs on line 260.

     

            private unsafe T[] GetVectorData<T>() where T : struct
            {
                if (uiVal == 0 || this.vectorPtr == IntPtr.Zero)
                    return new T[0];

                T[] data = new T[uiVal];
                uint tSize = (uint) Marshal.SizeOf(typeof(T));
               
                GCHandle pinningGCH = GCHandle.Alloc(data, GCHandleType.Pinned);
                try
                {
                    IntPtr dst = pinningGCH.AddrOfPinnedObject();
                    RtlMoveMemory(dst, this.vectorPtr, uiVal * tSize);       <= Error occurs here
                }
                finally
                {
                    pinningGCH.Free();
                }
               
                return data;
            }

    =============================================================================
    Here are the autos:

    +  dst 39919664 System.IntPtr
    +  pinningGCH {System.Runtime.InteropServices.GCHandle} System.Runtime.InteropServices.GCHandle
      tSize 1 uint
    +  this {Windows7.Sensors.Internal.PROPVARIANT} Windows7.Sensors.Internal.PROPVARIANT
    +  this.vectorPtr 2000930086731120640 System.IntPtr
      uiVal 40 ushort
    ===============================================================================
    Additional information: This only occurs for the ambient light sensor. I have the Windows 7 sensor development kit and if I modify the code to exclude this sensor everything runs juist fine. I am running VS 2008 on Windows 7 with all service packs.

    Thursday, May 21, 2009 6:31 PM

Answers

All replies