Example #1
0
        public void Modify(ViewModifyMode mode, Record record)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }

            uint ret = RemotableNativeMethods.MsiViewModify((int)this.Handle, (int)mode, (int)record.Handle);

            if (mode == ViewModifyMode.Insert || mode == ViewModifyMode.InsertTemporary)
            {
                record.IsFormatStringInvalid = true;
            }
            if (ret != 0)
            {
                throw InstallerException.ExceptionFromReturnCode(ret);
            }
        }
Example #2
0
        private ICollection <ValidationErrorInfo> InternalValidate(ViewModifyMode mode, Record record)
        {
            uint ret = RemotableNativeMethods.MsiViewModify((int)this.Handle, (int)mode, (int)record.Handle);

            if (ret == (uint)NativeMethods.Error.INVALID_DATA)
            {
                ICollection <ValidationErrorInfo> errorInfo = new List <ValidationErrorInfo>();
                while (true)
                {
                    uint          bufSize = 40;
                    StringBuilder column  = new StringBuilder("", (int)bufSize);
                    int           error   = RemotableNativeMethods.MsiViewGetError((int)this.Handle, column, ref bufSize);
                    if (error == -2 /*MSIDBERROR_MOREDATA*/)
                    {
                        column.Capacity = (int)++bufSize;
                        error           = RemotableNativeMethods.MsiViewGetError((int)this.Handle, column, ref bufSize);
                    }

                    if (error == -3 /*MSIDBERROR_INVALIDARG*/)
                    {
                        throw InstallerException.ExceptionFromReturnCode((uint)NativeMethods.Error.INVALID_PARAMETER);
                    }
                    else if (error == 0 /*MSIDBERROR_NOERROR*/)
                    {
                        break;
                    }

                    errorInfo.Add(new ValidationErrorInfo((ValidationError)error, column.ToString()));
                }

                return(errorInfo);
            }
            else if (ret != 0)
            {
                throw InstallerException.ExceptionFromReturnCode(ret);
            }
            return(null);
        }