照书上例子敲的,编译不通过,
出错提示为“不能实现成员ITrackingHandler”,
谁能帮帮忙?using System;
using System.ComponentModel;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Services;
using System.Runtime.Remoting.Channels;
namespace Hello
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
///
public class Hello:System.MarshalByRefObject
{
public Hello()
{
Console.WriteLine("Hello constructor called");
}
~Hello()
{
Console.WriteLine("Hello destructor called");
} public string Greeting(string name)
{
Console.WriteLine("Hello greeting called");
return "Hello,"+name;
}
public MySerialized GetMySerialized()
{
return new MySerialized(4711);
}
public MyRemote GetMyRemote()
{
return new MyRemote(4712);
}
}
[Serializable]
public class MySerialized
{
public MySerialized(int val)
{
a = val;
}
public void Foo()
{
Console.WriteLine("MySerialized.Foo called");
}
public int A
{
get
{
Console.WriteLine("MySerialized.A called");
return a;
}
set
{
a = value;
}
}
protected int a;
}
public class MyRemote: System.MarshalByRefObject
{
public MyRemote(int val)
{
a = val;
}
public void Foo()
{
Console.WriteLine("MyRemote.Foo.called");
}
public int A
{
get
{
Console.WriteLine("MyRemote.A called");
return a;
}
set
{
a = value;
}
}
protected int a;
}
public class TrackingHandler: ITrackingHandler
{
public TrackingHandler()
{
}
public void MarshaledObject(object obj,ObjRef or)
{
Console.WriteLine("---Marshaled Object "+
obj.GetType()+"---");
Console.WriteLine("Object URL:"+or.URI);
object[] channelData = or.ChannelInfo.ChannelData; foreach(object data in channelData)
{
ChannelDataStore dataStore = data as ChannelDataStore;
if(dataStore!=null)
{
foreach(string uri in dataStore.ChannelUris)
{
Console.WriteLine("Channel URI:"+uri);
}
}
}
Console.WriteLine("----------");
Console.WriteLine();
}
public void UnmarshaledObject(object obj,ObjRef or)
{
Console.WriteLine("UnMarshal");
}
public void Disconnected(object obj)
{
Console.WriteLine("Disconnect");
}
}}
出错提示为“不能实现成员ITrackingHandler”,
谁能帮帮忙?using System;
using System.ComponentModel;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Services;
using System.Runtime.Remoting.Channels;
namespace Hello
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
///
public class Hello:System.MarshalByRefObject
{
public Hello()
{
Console.WriteLine("Hello constructor called");
}
~Hello()
{
Console.WriteLine("Hello destructor called");
} public string Greeting(string name)
{
Console.WriteLine("Hello greeting called");
return "Hello,"+name;
}
public MySerialized GetMySerialized()
{
return new MySerialized(4711);
}
public MyRemote GetMyRemote()
{
return new MyRemote(4712);
}
}
[Serializable]
public class MySerialized
{
public MySerialized(int val)
{
a = val;
}
public void Foo()
{
Console.WriteLine("MySerialized.Foo called");
}
public int A
{
get
{
Console.WriteLine("MySerialized.A called");
return a;
}
set
{
a = value;
}
}
protected int a;
}
public class MyRemote: System.MarshalByRefObject
{
public MyRemote(int val)
{
a = val;
}
public void Foo()
{
Console.WriteLine("MyRemote.Foo.called");
}
public int A
{
get
{
Console.WriteLine("MyRemote.A called");
return a;
}
set
{
a = value;
}
}
protected int a;
}
public class TrackingHandler: ITrackingHandler
{
public TrackingHandler()
{
}
public void MarshaledObject(object obj,ObjRef or)
{
Console.WriteLine("---Marshaled Object "+
obj.GetType()+"---");
Console.WriteLine("Object URL:"+or.URI);
object[] channelData = or.ChannelInfo.ChannelData; foreach(object data in channelData)
{
ChannelDataStore dataStore = data as ChannelDataStore;
if(dataStore!=null)
{
foreach(string uri in dataStore.ChannelUris)
{
Console.WriteLine("Channel URI:"+uri);
}
}
}
Console.WriteLine("----------");
Console.WriteLine();
}
public void UnmarshaledObject(object obj,ObjRef or)
{
Console.WriteLine("UnMarshal");
}
public void Disconnected(object obj)
{
Console.WriteLine("Disconnect");
}
}}
解决方案 »
- tabcontrol的header 选中时的背景色怎么设置?我设了tabitem 的background是没选中时候的颜色,想设置选中后的颜色怎做
- C#操作excel工程表问题
- vs2005开发的基于ce的cs程序如何移植到mobile上,求教!
- 请问两个DataSet( ds1,ds2,结构一致! )如何得出ds2里有,但ds1里没有的数据。
- 拔掉网线出现ora12560,重新插上网线后,还有有这个错误,如何解决,不重起程序
- MDI子窗体问题
- ArrayList函数的返回值问题???????????????
- 有关csc编译
- DataView问题求助!!
- 高手们啊!我的Windows Service 的问题还没有解决啊,帮帮我吧!!
- 简单服务器处理XML问题
- 在线等待:c#的winform中怎样在datagrid中控制增删改功能
改为public void DisconnectedObject(object obj)