Remoting client exception

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?
 
S

Steven Cheng[MSFT]

Hi Sharon,


Hi Sharon,

Welcome to MSDN newsgroup.
Regarding on the "assembly not found ...." error when using remote event
handler in .net remoting application.... it is an expected behavior because
when we register a event handler of an remote object (SAO) in our client
application, our client class object(which expose that event handler
fucntion) will be dynamically invoked by the server object (when event is
fired...), in other word, the client object is acting as a server object
also( from the server object's perspective.....). So when the event fired,
the server object will try to find the metadata (assembly) of the client
class object, then "assembly not found exception" thrown out....

So to resolve the problem, we have to make the client object which expose
the event handler function also marshalByRef so that it can act as a server
object..... And there are some guys which use a certain shim class which
expose such event handler fucntions and act as a intermediate connectore
between our client app and server object (SAO)...

Here is a web article which mentioned such topic and provide an example
about using a shim class....

#Events and .NET Remoting
http://www.tomergabel.com/Events+And+NET+Remoting.aspx

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)





--------------------
| Thread-Topic: Remoting client exception
| thread-index: AcX414gSBEN0uOTjQp2+XkZ7F7FZkQ==
| X-WBNR-Posting-Host: 199.203.93.141
| From: =?Utf-8?B?U2hhcm9u?= <[email protected]>
| Subject: Remoting client exception
| Date: Sun, 4 Dec 2005 05:35:03 -0800
| Lines: 100
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 8bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:369260
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| 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?
|
|
| -------
| Thanks
| Sharon
|
 
S

Steven Cheng[MSFT]

Hi Sharon,

Does my suggestion in last reply helps a little? If there're anything else
we can help, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 160995001
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Mon, 05 Dec 2005 09:56:15 GMT
| Subject: RE: Remoting client exception
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| Message-ID: <HMhdnIY#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Lines: 140
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:369366
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Sharon,
|
|
| Hi Sharon,
|
| Welcome to MSDN newsgroup.
| Regarding on the "assembly not found ...." error when using remote event
| handler in .net remoting application.... it is an expected behavior
because
| when we register a event handler of an remote object (SAO) in our client
| application, our client class object(which expose that event handler
| fucntion) will be dynamically invoked by the server object (when event is
| fired...), in other word, the client object is acting as a server object
| also( from the server object's perspective.....). So when the event
fired,
| the server object will try to find the metadata (assembly) of the client
| class object, then "assembly not found exception" thrown out....
|
| So to resolve the problem, we have to make the client object which expose
| the event handler function also marshalByRef so that it can act as a
server
| object..... And there are some guys which use a certain shim class
which
| expose such event handler fucntions and act as a intermediate connectore
| between our client app and server object (SAO)...
|
| Here is a web article which mentioned such topic and provide an example
| about using a shim class....
|
| #Events and .NET Remoting
| http://www.tomergabel.com/Events+And+NET+Remoting.aspx
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
|
| --------------------
| | Thread-Topic: Remoting client exception
| | thread-index: AcX414gSBEN0uOTjQp2+XkZ7F7FZkQ==
| | X-WBNR-Posting-Host: 199.203.93.141
| | From: =?Utf-8?B?U2hhcm9u?= <[email protected]>
| | Subject: Remoting client exception
| | Date: Sun, 4 Dec 2005 05:35:03 -0800
| | Lines: 100
| | Message-ID: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 8bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Newsgroups: microsoft.public.dotnet.languages.csharp
| | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.languages.csharp:369260
| | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| |
| | 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?
| |
| |
| | -------
| | Thanks
| | Sharon
| |
|
|
 
S

Steven Cheng[MSFT]

You're welcome Sharon,

Please feel free to post here when you need any further assistance...

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: Remoting client exception
| thread-index: AcX/LE+uukYRGmtyRpivX1CBwMda0A==
| X-WBNR-Posting-Host: 199.203.93.141
| From: =?Utf-8?B?U2hhcm9u?= <[email protected]>
| References: <[email protected]>
<HMhdnIY#[email protected]>
<Wz8EeDy#[email protected]>
| Subject: RE: Remoting client exception
| Date: Mon, 12 Dec 2005 06:57:03 -0800
| Lines: 5
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:371002
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Yes, you did help.
|
| --
| Thanks
| Sharon
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top