class Server { static void Main(string[] args) { RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "server.exe.config"); // TrackingServices.RegisterTrackingHandler(new TrackingHandler()); Console.WriteLine("Server ready."); Console.ReadLine(); } public static void writestring(string a) { Console.WriteLine(a); } }public class TrackingHandler : ITrackingHandler { // Notify a handler that an object has been marshaled. public void MarshaledObject(Object obj, ObjRef or) { // Server.writestring("Tracking: An instance of" + obj.ToString() + "was marshaled. The instance HashCode is: " + obj.GetHashCode().ToString()); Console.WriteLine("Tracking: An instance of {0} was marshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString()); Console.WriteLine(System.DateTime.Now.ToString()); Console.WriteLine("ObjRef dump:"); if (or.ChannelInfo != null) { Console.WriteLine(" -- ChannelInfo: "); DumpChannelInfo(or.ChannelInfo); } if (or.EnvoyInfo != null) Console.WriteLine(" -- EnvoyInfo: " + or.EnvoyInfo.ToString()); if (or.TypeInfo != null) { Console.WriteLine(" -- TypeInfo: " + or.TypeInfo.ToString()); Console.WriteLine(" -- " + or.TypeInfo.TypeName); } if (or.URI != null) Console.WriteLine(" -- URI: " + or.URI.ToString());
// IPrincipal principal = Thread.CurrentPrincipal;
} private void DumpChannelInfo(IChannelInfo info) { foreach(object obj in info.ChannelData) { if(obj is ChannelDataStore) { foreach(string uri in ((ChannelDataStore)obj).ChannelUris) Console.WriteLine(" -- ChannelUris:" + uri); } } } // Notify a handler that an object has been unmarshaled. public void UnmarshaledObject(Object obj, ObjRef or) { Console.WriteLine("Tracking: An instance of {0} was unmarshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString()); } // Notify a handler that an object has been disconnected. public void DisconnectedObject(Object obj) { Console.WriteLine("Tracking: An instance of {0} was disconnected. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString()); Console.WriteLine(System.DateTime.Now.ToString()); } }
class Server { static void Main(string[] args) { RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "server.exe.config"); TrackingServices.RegisterTrackingHandler(new TrackingHandler()); Console.WriteLine("Server ready."); Console.ReadLine(); } public static void writestring(string a) { Console.WriteLine(a); } }public class TrackingHandler : ITrackingHandler { // Notify a handler that an object has been marshaled. public void MarshaledObject(Object obj, ObjRef or) { // Server.writestring("Tracking: An instance of" + obj.ToString() + "was marshaled. The instance HashCode is: " + obj.GetHashCode().ToString()); Console.WriteLine("Tracking: An instance of {0} was marshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString()); Console.WriteLine(System.DateTime.Now.ToString()); Console.WriteLine("ObjRef dump:"); if (or.ChannelInfo != null) { Console.WriteLine(" -- ChannelInfo: "); DumpChannelInfo(or.ChannelInfo); } if (or.EnvoyInfo != null) Console.WriteLine(" -- EnvoyInfo: " + or.EnvoyInfo.ToString()); if (or.TypeInfo != null) { Console.WriteLine(" -- TypeInfo: " + or.TypeInfo.ToString()); Console.WriteLine(" -- " + or.TypeInfo.TypeName); } if (or.URI != null) Console.WriteLine(" -- URI: " + or.URI.ToString());
// IPrincipal principal = Thread.CurrentPrincipal;
} private void DumpChannelInfo(IChannelInfo info) { foreach(object obj in info.ChannelData) { if(obj is ChannelDataStore) { foreach(string uri in ((ChannelDataStore)obj).ChannelUris) Console.WriteLine(" -- ChannelUris:" + uri); } } } // Notify a handler that an object has been unmarshaled. public void UnmarshaledObject(Object obj, ObjRef or) { Console.WriteLine("Tracking: An instance of {0} was unmarshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString()); } // Notify a handler that an object has been disconnected. public void DisconnectedObject(Object obj) { Console.WriteLine("Tracking: An instance of {0} was disconnected. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString()); Console.WriteLine(System.DateTime.Now.ToString()); }}上个错了
{
static void Main(string[] args)
{
RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "server.exe.config");
// TrackingServices.RegisterTrackingHandler(new TrackingHandler());
Console.WriteLine("Server ready.");
Console.ReadLine();
}
public static void writestring(string a)
{
Console.WriteLine(a);
}
}public class TrackingHandler : ITrackingHandler
{ // Notify a handler that an object has been marshaled.
public void MarshaledObject(Object obj, ObjRef or)
{
// Server.writestring("Tracking: An instance of" + obj.ToString() + "was marshaled. The instance HashCode is: " + obj.GetHashCode().ToString());
Console.WriteLine("Tracking: An instance of {0} was marshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());
Console.WriteLine(System.DateTime.Now.ToString());
Console.WriteLine("ObjRef dump:");
if (or.ChannelInfo != null)
{
Console.WriteLine(" -- ChannelInfo: ");
DumpChannelInfo(or.ChannelInfo);
}
if (or.EnvoyInfo != null)
Console.WriteLine(" -- EnvoyInfo: " + or.EnvoyInfo.ToString());
if (or.TypeInfo != null)
{
Console.WriteLine(" -- TypeInfo: " + or.TypeInfo.ToString());
Console.WriteLine(" -- " + or.TypeInfo.TypeName);
}
if (or.URI != null)
Console.WriteLine(" -- URI: " + or.URI.ToString());
// IPrincipal principal = Thread.CurrentPrincipal;
} private void DumpChannelInfo(IChannelInfo info)
{ foreach(object obj in info.ChannelData)
{
if(obj is ChannelDataStore)
{
foreach(string uri in ((ChannelDataStore)obj).ChannelUris)
Console.WriteLine(" -- ChannelUris:" + uri);
}
}
} // Notify a handler that an object has been unmarshaled.
public void UnmarshaledObject(Object obj, ObjRef or)
{
Console.WriteLine("Tracking: An instance of {0} was unmarshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());
} // Notify a handler that an object has been disconnected.
public void DisconnectedObject(Object obj)
{
Console.WriteLine("Tracking: An instance of {0} was disconnected. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());
Console.WriteLine(System.DateTime.Now.ToString());
}
}
{
static void Main(string[] args)
{
RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "server.exe.config");
TrackingServices.RegisterTrackingHandler(new TrackingHandler());
Console.WriteLine("Server ready.");
Console.ReadLine();
}
public static void writestring(string a)
{
Console.WriteLine(a);
}
}public class TrackingHandler : ITrackingHandler
{ // Notify a handler that an object has been marshaled.
public void MarshaledObject(Object obj, ObjRef or)
{
// Server.writestring("Tracking: An instance of" + obj.ToString() + "was marshaled. The instance HashCode is: " + obj.GetHashCode().ToString());
Console.WriteLine("Tracking: An instance of {0} was marshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());
Console.WriteLine(System.DateTime.Now.ToString());
Console.WriteLine("ObjRef dump:");
if (or.ChannelInfo != null)
{
Console.WriteLine(" -- ChannelInfo: ");
DumpChannelInfo(or.ChannelInfo);
}
if (or.EnvoyInfo != null)
Console.WriteLine(" -- EnvoyInfo: " + or.EnvoyInfo.ToString());
if (or.TypeInfo != null)
{
Console.WriteLine(" -- TypeInfo: " + or.TypeInfo.ToString());
Console.WriteLine(" -- " + or.TypeInfo.TypeName);
}
if (or.URI != null)
Console.WriteLine(" -- URI: " + or.URI.ToString());
// IPrincipal principal = Thread.CurrentPrincipal;
} private void DumpChannelInfo(IChannelInfo info)
{ foreach(object obj in info.ChannelData)
{
if(obj is ChannelDataStore)
{
foreach(string uri in ((ChannelDataStore)obj).ChannelUris)
Console.WriteLine(" -- ChannelUris:" + uri);
}
}
} // Notify a handler that an object has been unmarshaled.
public void UnmarshaledObject(Object obj, ObjRef or)
{
Console.WriteLine("Tracking: An instance of {0} was unmarshaled. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());
} // Notify a handler that an object has been disconnected.
public void DisconnectedObject(Object obj)
{
Console.WriteLine("Tracking: An instance of {0} was disconnected. The instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());
Console.WriteLine(System.DateTime.Now.ToString());
}}上个错了