服务器
public class MyRemotingObject : System.MarshalByRefObject
{
public void TestException()
{
throw new RemotingException ("message");
}
}
//可串行的异常类
[Serializable]
public class RemotingException : Exception
{
public RemotingException ()
{
}
public RemotingException (string message) : base(message)
{
}
}
客户端
public class Client
{
....
public void Test()
{
MyRemotingObject mro = new MyRemotingObject();
try
{
mro.TestException();
}
catch(RemotingException rex)
{
MessageBox.Show(rex.Message);
}
}
}
在同一台机器上测试可以通过,在不同机器上就无法串行该异常消息
服务器自己写的,原来一直用OUT 参数带出异常信息的。请教解决方法?
public class MyRemotingObject : System.MarshalByRefObject
{
public void TestException()
{
throw new RemotingException ("message");
}
}
//可串行的异常类
[Serializable]
public class RemotingException : Exception
{
public RemotingException ()
{
}
public RemotingException (string message) : base(message)
{
}
}
客户端
public class Client
{
....
public void Test()
{
MyRemotingObject mro = new MyRemotingObject();
try
{
mro.TestException();
}
catch(RemotingException rex)
{
MessageBox.Show(rex.Message);
}
}
}
在同一台机器上测试可以通过,在不同机器上就无法串行该异常消息
服务器自己写的,原来一直用OUT 参数带出异常信息的。请教解决方法?
解决方案 »
- xpath属性中出现中文字符,就无法筛选?
- C# 如何捕获所有编辑框焦点事件
- 如何在已创建好的图片上添加按钮,定位它的坐标,用鼠标事件能够点击这个按钮?
- 这样的SQL语句应该怎样写??
- .net下如何生成原生代码(native code)?
- HTTP协议转换问题??请教高手
- 今天生日晚上在单位加班,散分庆祝....
- 求教一下
- C#在对日外包的需求或职位怎么样?
- c#怎么调用自己用vb编写的dll组件
- 如何将visual C#.net 2003建的asp.net web应用程序移到其它计算机上?
- 写了个windows service程序,通过运行命令行实用工具 InstallUtil.exe 安装,为什么还是不行呢?
把服务器羰错误信息写到这个类中,在客户调用这个类
如
errorClass
{boolean flag;
string error
}
MyRemotingObject mro = new MyRemotingObject();
这句是取得本程序的,而不是远程对象
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参阅此消息的结尾。************** 异常文本 **************
System.Runtime.Remoting.RemotingException: 服务器遇到内部错误。有关更多信息,请打开服务器的 .config 文件中的 customErrors。Server stack trace:
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Linyi_Library.GzrybmkObj.CheckLogin(String sUserID, String sPassword)
at Linyi_Client.GZRYBMKInfo.CheckLogin(String sUserID, String sPassword)
at Linyi_Client.frmLogin.btnOK_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
Linyi_Client
程序集版本: 1.0.1.1
Win32 版本: 1.0.1.1
基本代码: file:///E:/源码空间/C%23/linyi/发布/Client/Linyi_Client.exe
----------------------------------------
System.Windows.Forms
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system.windows.forms.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------
Linyi_Library
程序集版本: 1.0.1.1
Win32 版本: 1.0.1.1
基本代码: file:///E:/源码空间/C%23/linyi/发布/Client/Linyi_Library.DLL
----------------------------------------
System.Data
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Runtime.Remoting
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system.runtime.remoting/1.0.5000.0__b77a5c561934e089/system.runtime.remoting.dll
----------------------------------------
System.Xml
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
mscorlib.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/windows/assembly/gac/mscorlib.resources/1.0.5000.0_zh-chs_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------************** JIT 调试 **************
计算机的配置文件(machine.config)的
system.windows.forms 节中必须设置 jitDebugging 值。
编译应用程序时还必须启用\r\n调试。\r\n\r\n例如: \r\n\r\n<configuration>\r\n <system.windows.forms jitDebugging="true" />\r\n</configuration>\r\n\r\n启用 JIT 调试后,任何未处理的异常\r\n都将被发送到此计算机上注册的 JIT 调试器,\r\n而不是由此对话框处理。\r\n
服务器端:
void Func()
{
throw new Exception("\n\n出错啦!");
}
客户端只要判断异常信息是否为自定义即可!