我有this post教我关于pdb文件和StackTrace。
这是代码。
using System;
// https://stackoverflow.com/questions/4474259/c-exception-handling-with-a-string-given-to-a-constructor
class WeekdayException : Exception {
public WeekdayException(String wday) : base("Illegal weekday: " + wday) {}
}
class TryCatchFinally
{
public static void Main()
{
try
{
throw new WeekdayException("thrown by try");
}
catch(WeekdayException weekdayException) {
Console.WriteLine(weekdayException.Message);
Console.WriteLine(weekdayException.StackTrace);
}
}
}
使用mono,我运行
dmcs /debug error.cs
mono error.exe
当我删除/ debug选项时,我收到的消息是一样的。
Illegal weekday: thrown by try
at TryCatchFinally.Main () [0x00000] in <filename unknown>:0
使用Visual Studio 2010,我运行
csc /debug error.cs
error
使用预期的行号获取此消息。
Illegal weekday: thrown by try
at TryCatchFinally.Main() in c:\error.cs:line 15
答案 0 :(得分:6)
你必须将--debug传递给mono。我不知道为什么会这样,我以前从没想过。
dmcs /debug error.cs
mono --debug error.exe