本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}