private static string UnmarshalString(SafeCoTaskMemHandle hValue, string handleName)
        {
            string value;
            bool   success;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                success = false;
                hValue.DangerousAddRef(ref success);
                if (success)
                {
                    value = Marshal.PtrToStringUni(hValue.DangerousGetHandle());
                    hValue.DangerousRelease();
                }
                else
                {
                    value = null;
                }
            }

            if (!success)
            {
                throw new InvalidOperationException("Failed to AddRef on " + handleName);
            }

            return(value);
        }
        private static string UnmarshalString(SafeCoTaskMemHandle hValue, string handleName)
        {
            string value;
            bool success;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                success = false;
                hValue.DangerousAddRef(ref success);
                if (success)
                {
                    value = Marshal.PtrToStringUni(hValue.DangerousGetHandle());
                    hValue.DangerousRelease();
                }
                else
                {
                    value = null;
                }
            }

            if (!success)
            {
                throw new InvalidOperationException("Failed to AddRef on " + handleName);
            }

            return value;
        }
 private static void SecureHandle(SafeCoTaskMemHandle handle, ref IntPtr ptr)
 {
     handle.SetHandle(ptr);
     ptr = IntPtr.Zero;
 }
 private static void SecureHandle(SafeCoTaskMemHandle handle, ref IntPtr ptr)
 {
     handle.SetHandle(ptr);
     ptr = IntPtr.Zero;
 }