Пример #1
0
        /// <summary>
        /// Verify an assembly's strong name
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="filePath"/> is null
        /// </exception>
        /// <exception cref="ArgumentException">
        /// If <paramref name="filePath"/> is empty
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// If verification could not complete
        /// </exception>
        /// <param name="filePath">assembly to verify</param>
        /// <param name="forceVerification">true to ignore the skip verify registry </param>
        /// <returns>result of the strong name verification</returns>
        public static bool VerifyAssembly(string filePath, bool forceVerification)
        {
            try
            {
                // do the verification
                bool wasVerified = false;
                if (!StrongNameNative.StrongNameSignatureVerificationEx(
                        filePath, forceVerification, ref wasVerified))
                {
                    return(false);
                }

                return(wasVerified);
            }
            catch (Exception)
            {
                return(false);
            }
        }