C# 禁用JIT调试
这个话题已经在很多问题中被问到和回答,我也做了尽职调查,但我就是不明白为什么我会有这个问题 testfailure.exe中的:C# 禁用JIT调试,c#,visual-studio-2012,visual-studio-debugging,jit,process.start,C#,Visual Studio 2012,Visual Studio Debugging,Jit,Process.start,这个话题已经在很多问题中被问到和回答,我也做了尽职调查,但我就是不明白为什么我会有这个问题 testfailure.exe中的: namespace testfailture { class Program { static void Main(string[] args) { try { throw new Exception("I want to report this in the parent window");
namespace testfailture
{
class Program
{
static void Main(string[] args)
{
try
{
throw new Exception("I want to report this in the parent window");
}
catch (Exception ex)
{
throw ex;
}
}
}
test.exe中的:
internal void Execute(string packageVersion)
{
Process exeProcess = new Process();
exeProcess.StartInfo.FileName = "testfailure.exe";
exeProcess.StartInfo.RedirectStandardOutput = true;
exeProcess.StartInfo.UseShellExecute = false;
exeProcess.StartInfo.CreateNoWindow = true;
try
{
exeProcess.Start();
Console.WriteLine(exeProcess.StandardOutput.ReadToEnd());
}
catch (Exception ex)
{
throw ex;
}
}
当我运行程序时,我会得到弹出窗口,在采取操作之前不会让程序继续运行
我认为这是由于JIT调试,所以我做了以下所有工作:
这是我遇到的一个问题,但最终我想做的是子流程将错误(而不是console.writeline,因为我想将其用于报告状态)报告给父级并显示在父级窗口中
有什么想法吗
顺便说一下,我正在使用Visual Studio Professional 2012。非常感谢你的帮助
谢谢
编辑#1----------------------------
我的流程完全希望一切都能正常工作,但我试图做的是为意外的失败编写代码。当失败时,我希望有一个良好的对话,以便我可以轻松快速地检测和调试 引发未处理的异常无法传递给父进程 但是,您可以做的是将数据写入StandardError,并在父进程中捕获该数据 以下示例来自:
Public Sub-Main()
Dim args()为字符串=Environment.GetCommandLineArgs()
Dim errorOutput As String=“”
'确保至少有一个命令行参数。
如果args.Length不射击messenger,请改为修复代码。异常不能跨越进程边界,您的程序应该像这样崩溃。你需要重新考虑你的策略,这是行不通的。是的,我同意。我的流程完全希望一切正常,但我正在为意外的失败编写代码。当这种情况发生时,我所做的将帮助我快速检测和调试代码>除非你想重置异常的调用堆栈。这正是我想要的!我应该对控制台做更多的研究。非常感谢。
Public Sub Main()
Dim args() As String = Environment.GetCommandLineArgs()
Dim errorOutput As String = ""
' Make sure that there is at least one command line argument.
If args.Length <= 1 Then
errorOutput += "You must include a filename on the command line." +
vbCrLf
End If
For ctr As Integer = 1 To args.GetUpperBound(0)
' Check whether the file exists.
If Not File.Exists(args(ctr)) Then
errorOutput += String.Format("'{0}' does not exist.{1}",
args(ctr), vbCrLf)
Else
' Display the contents of the file.
Dim sr As New StreamReader(args(ctr))
Dim contents As String = sr.ReadToEnd()
sr.Close()
Console.WriteLine("***** Contents of file '{0}':{1}{1}",
args(ctr), vbCrLf)
Console.WriteLine(contents)
Console.WriteLine("*****{0}", vbCrLf)
End If
Next
' Check for error conditions.
If Not String.IsNullOrEmpty(errorOutput) Then
' Write error information to a file.
Console.SetError(New StreamWriter(".\ViewTextFile.Err.txt"))
Console.Error.WriteLine(errorOutput)
Console.Error.Close()
' Reacquire the standard error stream.
Dim standardError As New StreamWriter(Console.OpenStandardError())
standardError.AutoFlush = True
Console.SetError(standardError)
Console.Error.WriteLine("{0}Error information written to ViewTextFile.Err.txt",
vbCrLf)
End If
End Sub