有点麻烦,不过可以自已标记一个debug模式,把出错信息写到一个文件里
public class Core
{
#region 写入日志 /// <summary>
/// 写入日志
/// </summary>
/// <param name="fileName">写入错误的文件名</param>
/// <param name="text">错误文本</param>
public static void WriteLog(string fileName,string text)
{
try
{
// 检查目录路径
if(fileName.IndexOf("\\") > -1)
{
string dirPath = fileName.Substring(0,fileName.LastIndexOf("\\"));
// 检查目录是否存在,如果不存在创建它
if(!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
} using(FileStream fs = new FileStream(fileName,FileMode.OpenOrCreate, FileAccess.Write))
{
StreamWriter w = new StreamWriter(fs);     
w.BaseStream.Seek(0, SeekOrigin.End);      
w.Write(text + "\r\n");
w.Flush();  

}
}
catch
{
}
} #endregion在catch块里 
if(debug)
{
 Core.WriteLog(文件名,出错信息);}