关于Remoting的问题 citymeteor(流星) :问题是我不知道该怎么解决啊!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 信道 tcp 已注册,同一个信道只能注册一次。跟一下,看看你注册了几次?或是多次调用注册过程?参考的对象种类不支持尝试的操作。”看看代码才知道。 citymeteor(流星) :谢谢!!!Server.CS:[STAThread] static void Main(string[] args) { // // TODO: 在此处添加代码以启动应用程序 // TcpServerChannel foChannel = new TcpServerChannel(8086); ShowChanelProperties(foChannel); ChannelServices.RegisterChannel(foChannel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteDLL.RemoteObject ),"RemoteObject",WellKnownObjectMode.SingleCall); Console.WriteLine("按任意键退出"); Console.ReadLine(); ChannelServices.UnregisterChannel(foChannel); }share.cs:public class CDocument : System.MarshalByRefObject { private int iDocID; private string sDocNumber; public int DocID { get { return iDocID; } set { iDocID = value; } } public string DocNumber { get { return sDocNumber; } set { sDocNumber = value; } } public CDocument() { // // TODO: 在此处添加构造函数逻辑 // iDocID = 0; sDocNumber = ""; } public void SetValue(int fiDocID,string fsDocNumber) { iDocID = fiDocID; sDocNumber = fsDocNumber; } } public class RemoteObject : System.MarshalByRefObject { public RemoteObject() { // // TODO: 在此处添加构造函数逻辑 // Console.WriteLine("实例化RemoteObject对象"); } ~RemoteObject() { Console.WriteLine("清除RemoteObject对象"); } public string ShowMsg(string fsMsg) { return "Hello:" + fsMsg; } public CDocument SetDocValue(CDocument foDoc) { foDoc.SetValue(1234,"cuibw"); return foDoc; } }client.cs:[STAThread] static void Main(string[] args) { // // TODO: 在此处添加代码以启动应用程序 // TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan); RemoteDLL.CDocument foDoc = new RemoteDLL.CDocument(); RemoteDLL.RemoteObject foRemote = (RemoteDLL.RemoteObject)Activator.GetObject(typeof(RemoteDLL.RemoteObject), "tcp://localhost:8086/RemoteObject"); if(foRemote == null && foDoc == null) { Console.WriteLine("未找到服务器"); } foRemote.SetDocValue(foDoc); }就在最后一句报错 C# 怎样修改默认的浏览器 求一个 利用线程和委托 刷新listview 数据的例子 4 4 10 10 任意加减乘除 编程实现得出24 高分求助C# 鼠标右键 c# 调用dll中结构体指针的问题 如何通过字符串获得html控件? SQL数据库取数据转换成XML保存到指定路径 求c#中文转拼音首字母的程序 请问当查询条件的个数不定的时候,如何动态生成select语句的where子句? 关于正则表达式的问题,如果替换一个字符串中的三个%s 调用MethodInfo的Invoke方法,如何使用out类型的参数? vb.net转c#这怎么写??(在线!急!)
谢谢!!!Server.CS:
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
TcpServerChannel foChannel = new TcpServerChannel(8086);
ShowChanelProperties(foChannel);
ChannelServices.RegisterChannel(foChannel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteDLL.RemoteObject ),"RemoteObject",WellKnownObjectMode.SingleCall);
Console.WriteLine("按任意键退出");
Console.ReadLine();
ChannelServices.UnregisterChannel(foChannel); }share.cs:public class CDocument : System.MarshalByRefObject
{
private int iDocID;
private string sDocNumber; public int DocID
{
get
{
return iDocID;
}
set
{
iDocID = value;
}
}
public string DocNumber
{
get
{
return sDocNumber;
}
set
{
sDocNumber = value;
}
}
public CDocument()
{
//
// TODO: 在此处添加构造函数逻辑
//
iDocID = 0;
sDocNumber = "";
}
public void SetValue(int fiDocID,string fsDocNumber)
{
iDocID = fiDocID;
sDocNumber = fsDocNumber;
}
}
public class RemoteObject : System.MarshalByRefObject
{
public RemoteObject()
{
//
// TODO: 在此处添加构造函数逻辑
//
Console.WriteLine("实例化RemoteObject对象");
} ~RemoteObject()
{
Console.WriteLine("清除RemoteObject对象");
} public string ShowMsg(string fsMsg)
{
return "Hello:" + fsMsg;
}
public CDocument SetDocValue(CDocument foDoc)
{
foDoc.SetValue(1234,"cuibw");
return foDoc;
}
}
client.cs:[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
RemoteDLL.CDocument foDoc = new RemoteDLL.CDocument();
RemoteDLL.RemoteObject foRemote = (RemoteDLL.RemoteObject)Activator.GetObject(typeof(RemoteDLL.RemoteObject), "tcp://localhost:8086/RemoteObject");
if(foRemote == null && foDoc == null)
{
Console.WriteLine("未找到服务器");
}
foRemote.SetDocValue(foDoc);
}就在最后一句报错