G
Guest
Hi,
I'm using the remoting, and I have a remoting object that has a public event
that other processes should register to it.
But when the client process is registering to the remote event, it throw the
following exception:
System.Runtime.Serialization.SerializationException {“Cannot find the
assembly Tester, Version=1.0.2164.27180, Culture=neutral,
PublicKeyToken=null.â€}
Note: The Tester assembly that contains the Tester class at the code below,
is the remote client process that tries to register to the event at the
Remoting object.
Here the code:
//////////////////////////////////////////////////////////////////
// The server process that export a remoting object
public class RemotingManager
{
private int m_port;
private TcpChannel m_Channel = null;
private MyRemoting m_remotingObj = null;
public RemotingManager(int port)
{
m_port = port;
BinaryServerFormatterSinkProvider serverProvider = new
BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = "9898";
props["name"] = "Gci:" + m_port.ToString();
props["typeFilterLevel"] = TypeFilterLevel.Full;
m_Channel = new TcpChannel(props, null, serverProvider);
ChannelServices.RegisterChannel(m_Channel);
m_remotingObj = new GciRemoteViewer();
RemotingServices.Marshal(m_remotingObj, "MyUri");
}
}
[Serializable()]
public delegate void MyEventHandler();
public class RemoteObject : MarshalByRefObject
{
public event MyEventHandler MyHandler;
public RemoteObject() {}
public void SomeMethod()
{
if( MyHandler != null )
MyHandler();
}
public override Object InitializeLifetimeService()
{ // By returning a null reference it tells the .NET remoting system
// that instances of this type are intended to have an infinite lifetime.
return null;
}
}
////////////////////////////////////////////////////////////////////////////////////////////
// The following code is at the client side process that get the proxy object.
public class Tester
{
public Tester()
{
TcpChannel channel = new TcpChannel(0); // No real need for that.
ChannelServices.RegisterChannel(channel ); // No real need for that.
// or: ChannelServices.RegisterChannel(new TcpChannel()); // No real need
for that.
RemoteObject remoteObject =
(RemoteObject)Activator.GetObject(typeof(RemoteObject),
"tcp://localhost:9898/MyUri");
if( remoteObject == null )
// ERROR !!!
else
{
// The following line throws the error !!!!
remoteObject.MyHandler += new
GciViewerAPI.MyEventHandler(this.HandlingMethod);
}
}
public void HandlingMethod()
{
// Doing somthing...
}
////////////////////////////////////////////////////////////////////////////////////////////
Can anybody tell me what why?
I'm using the remoting, and I have a remoting object that has a public event
that other processes should register to it.
But when the client process is registering to the remote event, it throw the
following exception:
System.Runtime.Serialization.SerializationException {“Cannot find the
assembly Tester, Version=1.0.2164.27180, Culture=neutral,
PublicKeyToken=null.â€}
Note: The Tester assembly that contains the Tester class at the code below,
is the remote client process that tries to register to the event at the
Remoting object.
Here the code:
//////////////////////////////////////////////////////////////////
// The server process that export a remoting object
public class RemotingManager
{
private int m_port;
private TcpChannel m_Channel = null;
private MyRemoting m_remotingObj = null;
public RemotingManager(int port)
{
m_port = port;
BinaryServerFormatterSinkProvider serverProvider = new
BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = "9898";
props["name"] = "Gci:" + m_port.ToString();
props["typeFilterLevel"] = TypeFilterLevel.Full;
m_Channel = new TcpChannel(props, null, serverProvider);
ChannelServices.RegisterChannel(m_Channel);
m_remotingObj = new GciRemoteViewer();
RemotingServices.Marshal(m_remotingObj, "MyUri");
}
}
[Serializable()]
public delegate void MyEventHandler();
public class RemoteObject : MarshalByRefObject
{
public event MyEventHandler MyHandler;
public RemoteObject() {}
public void SomeMethod()
{
if( MyHandler != null )
MyHandler();
}
public override Object InitializeLifetimeService()
{ // By returning a null reference it tells the .NET remoting system
// that instances of this type are intended to have an infinite lifetime.
return null;
}
}
////////////////////////////////////////////////////////////////////////////////////////////
// The following code is at the client side process that get the proxy object.
public class Tester
{
public Tester()
{
TcpChannel channel = new TcpChannel(0); // No real need for that.
ChannelServices.RegisterChannel(channel ); // No real need for that.
// or: ChannelServices.RegisterChannel(new TcpChannel()); // No real need
for that.
RemoteObject remoteObject =
(RemoteObject)Activator.GetObject(typeof(RemoteObject),
"tcp://localhost:9898/MyUri");
if( remoteObject == null )
// ERROR !!!
else
{
// The following line throws the error !!!!
remoteObject.MyHandler += new
GciViewerAPI.MyEventHandler(this.HandlingMethod);
}
}
public void HandlingMethod()
{
// Doing somthing...
}
////////////////////////////////////////////////////////////////////////////////////////////
Can anybody tell me what why?