Discussion:
One event is working but exactly the same another not.
(too old to reply)
Jamal
2009-07-04 15:25:02 UTC
Permalink
Hi guys,



I need a bit help if somebody had the same situation.

First in general the situation:

1) Two windows applications one acts is server another as a client

2) Communication goes via TcpChannel

3) Implemented apart class library containing only interfaces
(ISMSEchange.dll) and no other classes

4) Both application have reference to the ISMSEchange.dll

5) On the server side has been implemented a class (JMSMSDevice)
derived from MarshalByRefObject, which implements the interface IJMAGNDevice
from ISMSEchange.dll



6) Server application registers wellknownservertype IJMAGNDevice with
parameter Singletone. So it will be the same object on both server and
client side



7) Real instance of the object is create on server side by code
Activator.GetObject(GetType(IJMAGNDevice), . connection parameters .)



8) On the client application side the reference to the created object
is obtained as well by Activator.GetObject(GetType(IJMAGNDevice), .
connection parameters .)



Everything works fine, I can obtain references, read properties of the class
instance, call methods and see that it is the same instance.

Till I came up to events

I have introduce two events: OnOpen and OnClose, they have no
parameters for the sake of simplicity, no additional attributes.

Events are declared in interface IJMAGNDevice. Implemented within
JMSMSDevice.



Now we came up to the trouble situation: with event OnOpen no problem at
all. But with second event generated an error during binding to local
variable.



On the client side is declared:

Private withevents mDevice as IJMAGNDevice



And two event handlers:



Public sub mDevice_OnOpen() handles IJMAGNDevice.OnOpen

Try

UpdateInterface()

Catch ex as exception

LogErrorMessage("Unexpected error", ex)

End try

End sub



Public sub mDevice_OnClose () handles IJMAGNDevice.OnClose

Try

UpdateInterface()

Catch ex as exception

LogErrorMessage("Unexpected error", ex)

End try

End sub



Error comes with statement within loading form event:



mProxy = Ctype(Activator.GetObject(GetType(IJMAGNSettings),"tcp://127.0.0.1:20001/URI2"),
IJMAGNSettings)



mDevice = mProxy.SMSDevice 'Here comes an SerializationException "Cannot get
the member 'mDevice_OnClose'"



If I remark mDevice_OnClose event handler no exception. The event OnOpen
works how it should work: event fired on server and raised on client side.

If I rename OnOpen event it is still working, changing orders in declaration
event does not help as well.



The question is why one event is working properly and another does not work.
In general there is no difference in declaration and implementation of these
two events and their event handlers.



Thanks in advance if somebody has any clue. For me it looks like a bug in
remoting implementation

Jamal..
Richard
2009-10-02 03:36:01 UTC
Permalink
is the class in which you declared handlers derived from mbro?
Post by Jamal
Hi guys,
I need a bit help if somebody had the same situation.
1) Two windows applications one acts is server another as a client
2) Communication goes via TcpChannel
3) Implemented apart class library containing only interfaces
(ISMSEchange.dll) and no other classes
4) Both application have reference to the ISMSEchange.dll
5) On the server side has been implemented a class (JMSMSDevice)
derived from MarshalByRefObject, which implements the interface IJMAGNDevice
from ISMSEchange.dll
6) Server application registers wellknownservertype IJMAGNDevice with
parameter Singletone. So it will be the same object on both server and
client side
7) Real instance of the object is create on server side by code
Activator.GetObject(GetType(IJMAGNDevice), . connection parameters .)
8) On the client application side the reference to the created object
is obtained as well by Activator.GetObject(GetType(IJMAGNDevice), .
connection parameters .)
Everything works fine, I can obtain references, read properties of the class
instance, call methods and see that it is the same instance.
Till I came up to events
I have introduce two events: OnOpen and OnClose, they have no
parameters for the sake of simplicity, no additional attributes.
Events are declared in interface IJMAGNDevice. Implemented within
JMSMSDevice.
Now we came up to the trouble situation: with event OnOpen no problem at
all. But with second event generated an error during binding to local
variable.
Private withevents mDevice as IJMAGNDevice
Public sub mDevice_OnOpen() handles IJMAGNDevice.OnOpen
Try
UpdateInterface()
Catch ex as exception
LogErrorMessage("Unexpected error", ex)
End try
End sub
Public sub mDevice_OnClose () handles IJMAGNDevice.OnClose
Try
UpdateInterface()
Catch ex as exception
LogErrorMessage("Unexpected error", ex)
End try
End sub
mProxy = Ctype(Activator.GetObject(GetType(IJMAGNSettings),"tcp://127.0.0.1:20001/URI2"),
IJMAGNSettings)
mDevice = mProxy.SMSDevice 'Here comes an SerializationException "Cannot get
the member 'mDevice_OnClose'"
If I remark mDevice_OnClose event handler no exception. The event OnOpen
works how it should work: event fired on server and raised on client side.
If I rename OnOpen event it is still working, changing orders in declaration
event does not help as well.
The question is why one event is working properly and another does not work.
In general there is no difference in declaration and implementation of these
two events and their event handlers.
Thanks in advance if somebody has any clue. For me it looks like a bug in
remoting implementation
Jamal..
Loading...