.Net Remoting的研究学习:如何获得服务器端产生的错误
2007-09-10 15:26
555 查看
困扰我几天的问题终于解决了,新手就是新手,一个小问题往往都能困着你好几天!当然,当你解决掉他的时候的那种心情,那简直是无法比拟的,好比你一直便秘,蹲厕所腿都蹲麻了,就在你要放弃提裤子的时候,突然哄的一声,全通了,那滋味,自己想去吧。。。比喻不太恰当,看不下去的请关掉去趟厕所先啊!
我所遇到的问题是这样的:使用.net remoting开发项目,过程遇到一些BUG讯息,当我以自己电脑为服务器,也就是DEBUG模式的时候可以显示错误讯息,当通过服务器(另一个电脑)测试就出现一行“Server encountered an internal error. For more information, turn off customErrors in the server's .config file.”大概意思就是服务器错了,配置什么什么文件,就看不太懂了,其实改变下文件就应该可以的,我就是那么笨,没办法,算是个教训吧!
目前利用.net remoting开发三层架构系统,在中间层有catch语句,在debug本机模式下测试消息是可以通过remoting传递到前端显示,在远程测试的时候就总会出现同一错误“Server encountered an internal error. For more information, turn off customErrors in the server's .config file”!
在CSDN找到一方案
http://topic.csdn.net/t/20050603/15/4057264.html
但是按照所说的继承类后,catch无法认识这个类,出现错误并跳到相应的代码处!表明并未捕捉到!请问各位如何解决?
我所做的方式是,新建一类继承Exception,代码如下:
[Serializable()]
public class CustomException : System.Exception, ISerializable
{
public CustomException(string asMessage, Exception aeinner)
: base(asMessage, aeinner)
{ }
public CustomException()
: base()
{ }
public CustomException(string asMessage)
: base(asMessage)
{
}
protected CustomException(SerializationInfo asinfo, StreamingContext asContext)
: base(asinfo, asContext)
{
}
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter
= true)]
public override void GetObjectData(SerializationInfo asinfo, StreamingContext asContext)
{
base.GetObjectData(asinfo, asContext);
}
}
中间层方法如下:
public static string TestCatchMessage()
{
string sMessage = "这是一个异常讯息,如果接收正常,则说明中间层可以发送异常讯息到底前端!";
throw new ClbError.CustomException(sMessage);
return "Failure";
}
在前端.net remoting机制配置和接口都没有代码问题,
接口如下:
Public interface iGetData
{
String TestCatchMessage();
}
前端调用代码如下:
try
{
MessageBox.Show(FrontRemoting.Remoting.TestCatchMessage());
}
catch (ClbError.CustomException e)
{
string sErr1 = ClbError.ClsError.ShowErrorMessage(e);
FrontHelper.ShowMsg(sErr1);//自己写的弹出窗体方法
return;
}
异常状况为:跳转到错误的代码处,不认识ClbError.CustomException 类!
请教各位大侠如何解决?
通过BAIDU搜索大多是新建自定义Exception类,找到不少答案,但对我好像都没用,我觉得错误不在这里,Exception应该是可以传递到前面的,否则就不讲究了!
http://blog.gurock.com/articles/creating-custom-exceptions-in-dotnet/ http://www.c-sharpcorner.com/UploadFile/susanabraham/CustomExceptionHandling06022005011154AM/CustomExceptionHandling.aspx http://msdn.microsoft.com/msdnmag/issues/04/03/ExceptionsinCOM/#S2
这三篇文章说明的是如何建立Custom Exception类
试了很多遍,就是不行,后来才重视英语,复制那段英语去Google了一下,第一个没看明白!第二个就是正解!
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1781771&SiteID=1
原来在
TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
几句话就可以了,超级简单的问题让我忙了老半天,归纳一下,自己对.net 的机制还不熟悉,基础不牢靠!恩,加油!
我所遇到的问题是这样的:使用.net remoting开发项目,过程遇到一些BUG讯息,当我以自己电脑为服务器,也就是DEBUG模式的时候可以显示错误讯息,当通过服务器(另一个电脑)测试就出现一行“Server encountered an internal error. For more information, turn off customErrors in the server's .config file.”大概意思就是服务器错了,配置什么什么文件,就看不太懂了,其实改变下文件就应该可以的,我就是那么笨,没办法,算是个教训吧!
目前利用.net remoting开发三层架构系统,在中间层有catch语句,在debug本机模式下测试消息是可以通过remoting传递到前端显示,在远程测试的时候就总会出现同一错误“Server encountered an internal error. For more information, turn off customErrors in the server's .config file”!
在CSDN找到一方案
http://topic.csdn.net/t/20050603/15/4057264.html
但是按照所说的继承类后,catch无法认识这个类,出现错误并跳到相应的代码处!表明并未捕捉到!请问各位如何解决?
我所做的方式是,新建一类继承Exception,代码如下:
[Serializable()]
public class CustomException : System.Exception, ISerializable
{
public CustomException(string asMessage, Exception aeinner)
: base(asMessage, aeinner)
{ }
public CustomException()
: base()
{ }
public CustomException(string asMessage)
: base(asMessage)
{
}
protected CustomException(SerializationInfo asinfo, StreamingContext asContext)
: base(asinfo, asContext)
{
}
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter
= true)]
public override void GetObjectData(SerializationInfo asinfo, StreamingContext asContext)
{
base.GetObjectData(asinfo, asContext);
}
}
中间层方法如下:
public static string TestCatchMessage()
{
string sMessage = "这是一个异常讯息,如果接收正常,则说明中间层可以发送异常讯息到底前端!";
throw new ClbError.CustomException(sMessage);
return "Failure";
}
在前端.net remoting机制配置和接口都没有代码问题,
接口如下:
Public interface iGetData
{
String TestCatchMessage();
}
前端调用代码如下:
try
{
MessageBox.Show(FrontRemoting.Remoting.TestCatchMessage());
}
catch (ClbError.CustomException e)
{
string sErr1 = ClbError.ClsError.ShowErrorMessage(e);
FrontHelper.ShowMsg(sErr1);//自己写的弹出窗体方法
return;
}
异常状况为:跳转到错误的代码处,不认识ClbError.CustomException 类!
请教各位大侠如何解决?
通过BAIDU搜索大多是新建自定义Exception类,找到不少答案,但对我好像都没用,我觉得错误不在这里,Exception应该是可以传递到前面的,否则就不讲究了!
http://blog.gurock.com/articles/creating-custom-exceptions-in-dotnet/ http://www.c-sharpcorner.com/UploadFile/susanabraham/CustomExceptionHandling06022005011154AM/CustomExceptionHandling.aspx http://msdn.microsoft.com/msdnmag/issues/04/03/ExceptionsinCOM/#S2
这三篇文章说明的是如何建立Custom Exception类
试了很多遍,就是不行,后来才重视英语,复制那段英语去Google了一下,第一个没看明白!第二个就是正解!
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1781771&SiteID=1
原来在
TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
几句话就可以了,超级简单的问题让我忙了老半天,归纳一下,自己对.net 的机制还不熟悉,基础不牢靠!恩,加油!
相关文章推荐
- linux ulimit的使用,如何产生core文件,调试段错误
- 软链接ln -s以及如何解决其产生“Too many levels of symbolic links ”的错误?
- 研究生阶段如何学习、做研究(超棒)
- Sharepoint学习笔记---Debug&TroubleShooting-如何让Sharepoint2010网站返回详细错误信息
- 如何学习游戏服务器端编程和书籍推荐
- 运行IE浏览器产生指令引用内存错误如何解决?
- 如何定位WinCE产生Data Abort错误的位置
- 如何定位WinCE产生Data Abort错误的位置
- wpf学习笔记-如何获得MS定义好的模版
- 延迟初始化错误(ERROR LazyInitializer)是如何产生的
- 【转】SVN错误如何产生及解决方法专家剖析
- 学习建议:如何做好研究[10 Steps Toward Better Research]
- 如何解决导出DBF时“字段将不能置于记录中”错误?记录过大错误产生原因
- Midas如何在服务器端自动产生流水号
- 如何用.net Remoting实现一个客户端需要连接多个服务器端?
- 如何设置才能获得电脑蓝屏产生的转储文件啊
- Midas如何在服务器端自动产生流水号
- [原创]java WEB学习笔记67:Struts2 学习之路-- 类型转换概述, 类型转换错误修改,如何自定义类型转换器
- 错误蓝屏死机重启产生的.dmp文件如何打开以及如何分析蓝屏的原因
- 用户研究(4)教你如何获得用户的芳心