日期:2014-05-18  浏览次数:20470 次

抛出异常的类的问题:发生类型为AppException 的异常;
发生类型为   forum.DataObject.AppException   的异常。  
说明:   执行当前   Web   请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  

异常详细信息:   forum.DataObject.AppException:   发生类型为   forum.DataObject.AppException   的异常。

源错误:  


行   156: if(users.Tables[0].Rows.Count   ==   0)
行   157: {
行   158: throw   new   AppException( "No   user   found   on   file   for   email: "   +   emailAddress);
行   159:
行   160: }
 

源文件:   c:\inetpub\wwwroot\forum\accounts_data\user.cs         行:   158  
堆栈跟踪:  


[AppException:   发生类型为   forum.DataObject.AppException   的异常。]

附AppException.cs代码:
 
using   System;
using   System.Diagnostics;

namespace   forum.DataObject
{
public   class   AppException:   System.Exception
{
public   AppException()
{
LogEvent( "系统产生异常 ");
}

public   AppException(string   message)
{
LogEvent(message);
}

public   AppException(string   message,   Exception   innerException)
{
LogEvent(message);
if   (innerException   !=   null)
{
LogEvent(innerException.Message);
}
}

private   void   LogEvent(string   message)
{
if   (!EventLog.SourceExists( "forum.com "))
{
EventLog.CreateEventSource( "forum.com ",   "Application ");
}
EventLog.WriteEntry( "forum.com ",   message,   EventLogEntryType.Error);
}
}


}


------解决方案--------------------
Tables[0]中没有数据就抛出异常
这个不是错误,而是业务逻辑控制。
你只需要在调用的地方try catch并处理这个异常就可以了。