1
我是.NET Remoting和C#的新手。我需要一个客户端/服务器应用程序,并希望通过.NET Remoting来处理这个问题。我已经为远程对象EchoServer类写了一个类库,并带有一些测试方法。.NET Remoting:在RegisterWellKnownServiceType上的“Value NULL”异常
我添加到Visual Studio中的服务器项目中的类库。程序集“System.Runtime.Remoting”我也添加了。
以下是我的服务器代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using Remoting; //Namespace Lib
namespace Server
{
public partial class Server : Form
{
public Server()
{
InitializeComponent();
TcpChannel serverChannel = null;
try
{
serverChannel = new TcpChannel(9998);
lvStatus.Items.Add("Server is listening on port 8089...");
string strIn = "";
ChannelServices.RegisterChannel(serverChannel, true);
RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("Remoting.EchoServer, remoting_dll"), "Echo", WellKnownObjectMode.SingleCall);
}
catch (Exception ex)
{
ChannelServices.UnregisterChannel(serverChannel);
MessageBox.Show(ex.Message.ToString());
}
}
}
}
如果我启动服务器时,我会得到一个异常:
的值不能为NULL 参数名称:类型
我试过一些教程的其他代码,但我会得到相同的excetion,如果远程对象的类是im,作为一个类库有特色,或者直接在我的项目中作为一个类。