private byte[] SerializeToBlob() { System.Runtime.InteropServices.ComTypes.STATSTG sTATSTG; byte[] numArray = null; IStream stream = null; IntPtr zero = IntPtr.Zero; try { stream = IWbemClassObjectFreeThreaded.CreateStreamOnHGlobal(IntPtr.Zero, 1); IWbemClassObjectFreeThreaded.CoMarshalInterface(stream, ref IWbemClassObjectFreeThreaded.IID_IWbemClassObject, this.pWbemClassObject, 2, IntPtr.Zero, 2); stream.Stat(out sTATSTG, 0); numArray = new byte[sTATSTG.cbSize]; zero = IWbemClassObjectFreeThreaded.GlobalLock(IWbemClassObjectFreeThreaded.GetHGlobalFromStream(stream)); Marshal.Copy(zero, numArray, 0, (int)sTATSTG.cbSize); } finally { if (zero != IntPtr.Zero) { IWbemClassObjectFreeThreaded.GlobalUnlock(zero); } if (stream != null) { Marshal.ReleaseComObject(stream); } } GC.KeepAlive(this); return(numArray); }