本文整理汇总了C#中System.ApplicationException.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationException.ToString方法的具体用法?C# ApplicationException.ToString怎么用?C# ApplicationException.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ApplicationException
的用法示例。
在下文中一共展示了ApplicationException.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: log_an_assembly_failure
public void log_an_assembly_failure()
{
var package = new StubPackage("a");
var exception = new ApplicationException("didn't work");
var theFileNameOfTheAssembly = "assembly.dll";
diagnostics.LogAssemblyFailure(package, theFileNameOfTheAssembly, exception);
var log = diagnostics.LogFor(package);
log.Success.ShouldBeFalse();
log.FullTraceText().Contains(exception.ToString()).ShouldBeTrue();
log.FullTraceText().ShouldContain("Failed to load assembly at '{0}'".ToFormat(theFileNameOfTheAssembly));
}
示例2: OnSaveOptions
/// <summary>
/// Overrides Package.OnSaveOptions()
/// Invoked by the Package class when there are options to be saved to the solution file.
/// </summary>
/// <param name="key">The name of the option key to save.</param>
/// <param name="stream">The stream to save the option data to.</param>
protected override void OnSaveOptions(string key, Stream stream)
{
try
{
if (0 == string.Compare(key, CommandLineOptionKey))
{
Logging.WriteLine("Saving CommandLineEditor options");
CommandLineEditor.SaveOptions(stream);
}
else if (0 == string.Compare(key, BatchBuildSetsOptionKey))
{
Logging.WriteLine("Saving BatchBuilder options");
BatchBuilder.SaveOptions(stream);
}
}
catch (Exception Ex)
{
// Couldn't save options
Exception AppEx = new ApplicationException("OnSaveOptions() failed with key " + key, Ex);
Logging.WriteLine(AppEx.ToString());
throw AppEx;
}
}
示例3: ComboHandler
/// Called by combo control to query the text to display or to apply newly-entered text
private void ComboHandler(object Sender, EventArgs Args)
{
try
{
var OleArgs = (OleMenuCmdEventArgs)Args;
string InString = OleArgs.InValue as string;
if (InString != null)
{
// New text set on the combo - set the command line property
DesiredCommandLine = null;
CommitCommandLineText(InString);
}
else if (OleArgs.OutValue != IntPtr.Zero)
{
string EditingString = null;
if (OleArgs.InValue != null)
{
object[] InArray = OleArgs.InValue as object[];
if (InArray != null && 0 < InArray.Length)
{
EditingString = InArray.Last() as string;
}
}
string TextToDisplay = string.Empty;
if (EditingString != null)
{
// The control wants to put EditingString in the box
TextToDisplay = DesiredCommandLine = EditingString;
}
else
{
// This is always hit at the end of interaction with the combo
if (DesiredCommandLine != null)
{
TextToDisplay = DesiredCommandLine;
DesiredCommandLine = null;
CommitCommandLineText(TextToDisplay);
}
else
{
TextToDisplay = MakeCommandLineComboText();
}
}
Marshal.GetNativeVariantForObject(TextToDisplay, OleArgs.OutValue);
}
}
catch (Exception ex)
{
Exception AppEx = new ApplicationException("CommandLineEditor threw an exception in ComboHandler()", ex);
Logging.WriteLine(AppEx.ToString());
throw AppEx;
}
}
示例4: CodeBug
/// <summary>
/// Throws RuntimeException to indicate failed assertion.
/// The function never returns and its return type is RuntimeException
/// only to be able to write <tt>throw EcmaScriptHelper.CodeBug()</tt> if plain
/// <tt>EcmaScriptHelper.CodeBug()</tt> triggers unreachable code error.
/// </summary>
public static ApplicationException CodeBug()
{
ApplicationException ex = new ApplicationException ("FAILED ASSERTION");
Console.Error.WriteLine (ex.ToString ());
throw ex;
}
示例5: SaveOptions
/// <summary>
/// Called from the package class when there are options to be written to the solution file.
/// </summary>
/// <param name="Stream">The stream to save the option data to.</param>
public void SaveOptions(Stream Stream)
{
try
{
using (BinaryWriter Writer = new BinaryWriter(Stream))
{
Writer.Write(_BuildJobSetsCollection.Count);
foreach (var Set in _BuildJobSetsCollection)
{
Writer.Write(Set.Name);
Writer.Write(Set.BuildJobs.Count);
foreach (var Job in Set.BuildJobs)
{
Writer.Write(Job.Project.FullName);
Writer.Write(Job.Project.Name);
Writer.Write(Job.Config);
Writer.Write(Job.Platform);
Writer.Write(Enum.GetName(typeof(BuildJob.BuildJobType), Job.JobType) ?? "INVALIDJOBTYPE");
}
}
}
}
catch (Exception ex)
{
Exception AppEx = new ApplicationException("BatchBuilder failed to save options to .suo", ex);
Logging.WriteLine(AppEx.ToString());
throw AppEx;
}
}
示例6: LoadOptions
/// <summary>
/// Called from the package class when there are options to be read out of the solution file.
/// </summary>
/// <param name="Stream">The stream to load the option data from.</param>
public void LoadOptions(Stream Stream)
{
try
{
_BuildJobSetsCollection.Clear();
using (BinaryReader Reader = new BinaryReader(Stream))
{
int SetCount = Reader.ReadInt32();
for (int SetIdx = 0; SetIdx < SetCount; SetIdx++)
{
BuildJobSet LoadedSet = new BuildJobSet();
LoadedSet.Name = Reader.ReadString();
int JobCount = Reader.ReadInt32();
for (int JobIdx = 0; JobIdx < JobCount; JobIdx++)
{
Utils.SafeProjectReference ProjectRef = new Utils.SafeProjectReference { FullName = Reader.ReadString(), Name = Reader.ReadString() };
string Config = Reader.ReadString();
string Platform = Reader.ReadString();
BuildJob.BuildJobType JobType;
if (Enum.TryParse(Reader.ReadString(), out JobType))
{
LoadedSet.BuildJobs.Add(new BuildJob(ProjectRef, Config, Platform, JobType));
}
}
_BuildJobSetsCollection.Add(LoadedSet);
}
}
EnsureDefaultBuildJobSet();
if (SetCombo.SelectedItem == null)
{
SetCombo.SelectedItem = _BuildJobSetsCollection[0];
}
}
catch (Exception ex)
{
Exception AppEx = new ApplicationException("BatchBuilder failed to load options from .suo", ex);
Logging.WriteLine(AppEx.ToString());
throw AppEx;
}
}