当前位置: 首页>>代码示例>>C#>>正文


C# TaskLoggingHelper.LogErrorFromException方法代码示例

本文整理汇总了C#中Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorFromException方法的典型用法代码示例。如果您正苦于以下问题:C# TaskLoggingHelper.LogErrorFromException方法的具体用法?C# TaskLoggingHelper.LogErrorFromException怎么用?C# TaskLoggingHelper.LogErrorFromException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.Utilities.TaskLoggingHelper的用法示例。


在下文中一共展示了TaskLoggingHelper.LogErrorFromException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadKeyFile

        /// <summary>
        /// Reads contents of a key file. Reused from vsdesigner code.
        /// </summary>
        /// <param name="log"></param>
        /// <param name="keyFile"></param>
        /// <param name="keyPair"></param>
        /// <param name="publicKey"></param>
        internal static void ReadKeyFile(TaskLoggingHelper log, string keyFile, out StrongNameKeyPair keyPair, out byte[] publicKey)
        {
            // Initialize parameters
            keyPair = null;
            publicKey = null;

            byte[] keyFileContents;

            try
            {
                // Read the stuff from the file stream
                using (FileStream fs = new FileStream(keyFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    keyFileContents = new byte[(int)fs.Length];
                    fs.Read(keyFileContents, 0, (int)fs.Length);
                }
            }
            catch (ArgumentException e)
            {
                log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", keyFile);
                log.LogErrorFromException(e);
                throw new StrongNameException(e);
            }
            catch (IOException e)
            {
                log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", keyFile);
                log.LogErrorFromException(e);
                throw new StrongNameException(e);
            }
            catch (SecurityException e)
            {
                log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", keyFile);
                log.LogErrorFromException(e);
                throw new StrongNameException(e);
            }

            // Make a new key pair from what we read
            StrongNameKeyPair snp = new StrongNameKeyPair(keyFileContents);

            // If anything fails reading the public key portion of the strong name key pair, then
            // assume that keyFile contained only the public key portion of the public/private pair.
            try
            {
                publicKey = snp.PublicKey;

                // If we didn't throw up to this point then we have a valid public/private key pair,
                // so assign the object just created above to the out parameter.  
                keyPair = snp;
            }
            catch (ArgumentException)
            {
                publicKey = keyFileContents;
            }
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:61,代码来源:StrongNameUtils.cs

示例2: ReadKeyFile

 internal static void ReadKeyFile(TaskLoggingHelper log, string keyFile, out StrongNameKeyPair keyPair, out byte[] publicKey)
 {
     byte[] buffer;
     keyPair = null;
     publicKey = null;
     try
     {
         using (FileStream stream = new FileStream(keyFile, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             buffer = new byte[(int) stream.Length];
             stream.Read(buffer, 0, (int) stream.Length);
         }
     }
     catch (ArgumentException exception)
     {
         log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", new object[] { keyFile });
         log.LogErrorFromException(exception);
         throw new StrongNameException(exception);
     }
     catch (IOException exception2)
     {
         log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", new object[] { keyFile });
         log.LogErrorFromException(exception2);
         throw new StrongNameException(exception2);
     }
     catch (SecurityException exception3)
     {
         log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", new object[] { keyFile });
         log.LogErrorFromException(exception3);
         throw new StrongNameException(exception3);
     }
     StrongNameKeyPair pair = new StrongNameKeyPair(buffer);
     try
     {
         publicKey = pair.PublicKey;
         keyPair = pair;
     }
     catch (ArgumentException)
     {
         publicKey = buffer;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:42,代码来源:StrongNameUtils.cs

示例3: GetStrongNameKey

 internal static void GetStrongNameKey(TaskLoggingHelper log, string keyFile, string keyContainer, out StrongNameKeyPair keyPair, out byte[] publicKey)
 {
     keyPair = null;
     publicKey = null;
     if ((keyContainer != null) && (keyContainer.Length != 0))
     {
         try
         {
             keyPair = new StrongNameKeyPair(keyContainer);
             publicKey = keyPair.PublicKey;
             return;
         }
         catch (SecurityException exception)
         {
             log.LogErrorWithCodeFromResources("StrongNameUtils.BadKeyContainer", new object[] { keyContainer });
             log.LogErrorFromException(exception);
             throw new StrongNameException(exception);
         }
         catch (ArgumentException exception2)
         {
             log.LogErrorWithCodeFromResources("StrongNameUtils.BadKeyContainer", new object[] { keyContainer });
             log.LogErrorFromException(exception2);
             throw new StrongNameException(exception2);
         }
     }
     if ((keyFile != null) && (keyFile.Length != 0))
     {
         ReadKeyFile(log, keyFile, out keyPair, out publicKey);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:StrongNameUtils.cs

示例4: GetStrongNameKey

 /// <summary>
 /// Given a key file or container, extract private/public key data. Reused from vsdesigner code.
 /// </summary>
 /// <param name="log"></param>
 /// <param name="keyFile"></param>
 /// <param name="keyContainer"></param>
 /// <param name="keyPair"></param>
 /// <param name="publicKey"></param>
 internal static void GetStrongNameKey(TaskLoggingHelper log, string keyFile, string keyContainer, out StrongNameKeyPair keyPair, out byte[] publicKey)
 {
     // Gets either a strong name key pair from the key file or a key container.
     // If keyFile and keyContainer are both null/zero length then returns null.
     // Initialize parameters
     keyPair = null;
     publicKey = null;
     if (keyContainer != null && keyContainer.Length != 0)
     {
         try
         {
             keyPair = new StrongNameKeyPair(keyContainer);
             publicKey = keyPair.PublicKey;
         }
         catch (SecurityException e)
         {
             log.LogErrorWithCodeFromResources("StrongNameUtils.BadKeyContainer", keyContainer);
             log.LogErrorFromException(e);
             throw new StrongNameException(e);
         }
         catch (ArgumentException e)
         {
             log.LogErrorWithCodeFromResources("StrongNameUtils.BadKeyContainer", keyContainer);
             log.LogErrorFromException(e);
             throw new StrongNameException(e);
         }
     }
     else if (keyFile != null && keyFile.Length != 0)
     {
         ReadKeyFile(log, keyFile, out keyPair, out publicKey);
     }
 }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:40,代码来源:StrongNameUtils.cs

示例5: DoWork

		public static bool DoWork(dynamic taskOptions, TaskLoggingHelper log) {
			var options = GetOptions(taskOptions, log);
			if (options == null)
				return false;

			var driver = new CompilerDriver(new TaskErrorReporter(log));
			try {
				return driver.Compile(options);
			}
			catch (Exception ex) {
				log.LogErrorFromException(ex);
				return false;
			}
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:14,代码来源:Worker.cs


注:本文中的Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorFromException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。