WCF服务不定期错误
光原 2012-09-27 12:30:03 本地测试,远程部署都完全没问题。但是运行一段时间后WCF会出现错误,提示未将对象引用错误,即对象是空的,3到5天出一次异常,
代码结构:
后台:
public class Srv_Bas : Srv.Srv_Master, ISrv_Bas
{
BL_Base bl_BaseInfo;
public Srv_Bas()
{
bl_BaseInfo = new BL_Base(subsystemModuleData.Bas.DBid);
bl_BaseInfo.subsystemModuleData = subsystemModuleData;
masterbl = bl_BaseInfo;
}
}
public class Srv_Master
{
public DataTable getDataTable(string strSql)
{
if (masterbl == null)
throw new Exception("masterbl is null");
if (String.IsNullOrWhiteSpace(strSql))
throw new Exception("strSql IsNullOrWhiteSpace");
return masterbl.getDataTable(strSql);
}
}
前台:
Type type = srvClient.GetType();
try
{
return (DataTable)type.InvokeMember("getDataTable", System.Reflection.BindingFlags.Default
| System.Reflection.BindingFlags.InvokeMethod, null, srvClient, new object[] { strSql });
}
catch (Exception _e)
{
string InterExceptionMsg="";
if (_e.InnerException !=null)
InterExceptionMsg= _e.InnerException.Message;
throw new Exception("方法getDataTable(" + strSql + ")出错了。\r" + _e.Message + "\rInnerException:" + InterExceptionMsg);
}