提示:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。下面是我的全部代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;using System.Runtime.Serialization.Formatters;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Serialization;using DelegateObject;namespace Server
{
public partial class Form1: Form
{
public Form1( )
{
InitializeComponent( );
} private void Form1_Load( object sender, EventArgs e )
{ RemotingConfiguration.Configure( @"F:\DotnetTest\RemotingDemo\Server\Server\Server.config"); this.textBox1.Text += "Server Started!";
}
}
}Server.config<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="DelegateObject.ServerObj, DelegateObject"
objectUri="Obj.soap"
/>
</service>
<channels>
<channel ref="tcp" port="9000">
<serverProviders>
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;using System.Runtime.Serialization.Formatters;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Serialization;using DelegateObject;namespace Server
{
public partial class Form1: Form
{
public Form1( )
{
InitializeComponent( );
} private void Form1_Load( object sender, EventArgs e )
{ RemotingConfiguration.Configure( @"F:\DotnetTest\RemotingDemo\Server\Server\Server.config"); this.textBox1.Text += "Server Started!";
}
}
}Server.config<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="DelegateObject.ServerObj, DelegateObject"
objectUri="Obj.soap"
/>
</service>
<channels>
<channel ref="tcp" port="9000">
<serverProviders>
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
解决方案 »
- 关于正则表达式,奇怪啊!
- dataGridView 与数据库绑定
- 求救!!!使用Remoting的IPC时候的问题,我返回的错误消息是“???????????customexception???????”
- dropdownlist取不到值大家帮助我看看
- 请问各位在做Web开发如Mis信息系统时.哪个数据显示控件都是用GridView吧! 现在就是Gridview显示栏位大小一般怎么控件?
- 300 高分求 winform,源程序(c#),erp 相关 最好
- 求RGB和CMYK的互相转换组件
- 控制台程序怎么实现登陆功能?
- 要代码?
- 有会做赛尔号外挂的么!
- C#能不能在form_load中关闭本窗体?
- 大家来讨论下这个数据库语句怎么写有关于DataTime类型数据的
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Serialization;using DelegateObject;namespace Receiver
{
public partial class Form1: Form
{
private ServerObj obj = null; public Form1( )
{
InitializeComponent( );
} private void Form1_Load( object sender, EventArgs e )
{
RemotingConfiguration.Configure( @"F:\DotnetTest\RemotingDemo\Server\Receiver\Receiver.config" ); obj = ( ServerObj )Activator.GetObject( typeof( ServerObj ), "tcp://localhost:9000/Obj.soap" );
ReceiverObj rObj = new ReceiverObj( );
rObj.ReceiverEvent += new DelegateObjHandle( Refresh_Mohed );
obj.Sending += new DelegateObjHandle( rObj.OnReceiverEvent );
} private void Refresh_Mohed( string value )
{
this.textBox1.Text += value;
}
}
}Receiver.config<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type="DelegateObject.ServerObj, DelegateObject"
url="tcp://localhost:9000/Obj.soap" />
</client>
<channels>
<channel
ref="tcp"
port="0">
<serverProviders>
<provider ref="wsdl" />
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;using System.Collections;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Serialization;using DelegateObject;namespace Client
{
public partial class Form1: Form
{
private ServerObj obj;
public Form1( )
{
InitializeComponent( );
} private void Form1_Load( object sender, EventArgs e )
{
BinaryServerFormatterSinkProvider server = new BinaryServerFormatterSinkProvider( );
BinaryClientFormatterSinkProvider client = new BinaryClientFormatterSinkProvider( );
server.TypeFilterLevel = TypeFilterLevel.Full; IDictionary props = new Hashtable( );
props[ "port" ] = 0; TcpChannel tcp = new TcpChannel( props, client, server );
ChannelServices.RegisterChannel( tcp ); obj = ( ServerObj )Activator.GetObject( typeof( ServerObj ), "tcp://localhost:9000/Obj.soap" );
} private void button1_Click( object sender, EventArgs e )
{
obj.OnSending( this.textBox1.Text );
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;namespace DelegateObject
{
public delegate void DelegateObjHandle( string value ); public class ServerObj:MarshalByRefObject
{
public override object InitializeLifetimeService( )
{
return null;
} public void OnSending( string value )
{
if ( Sending != null )
{
Sending( value );
}
}
public event DelegateObjHandle Sending;
}
public class ReceiverObj: MarshalByRefObject
{
public ReceiverObj( )
{
// obj.Sending += new DelegateObjHandle( OnReceiverEvent );
} public override object InitializeLifetimeService( )
{
return null;
} public void OnReceiverEvent( string value )
{
if ( ReceiverEvent != null )
{
ReceiverEvent( value );
}
}
public event DelegateObjHandle ReceiverEvent; } public interface IServerObj
{
void OnSending( string value );
event DelegateObjHandle Sending;
}
}