Remoting event.  
Author Message
Parwej Ahamad





PostPosted: .NET Remoting and Runtime Serialization, Remoting event. Top

i have made a remote app. server generate event on client side. it's working well.

Now i have redesign remote server under the window service.

problem is that it's not generate event at client side by the server.
without window service it's running well.
we can generate event under the window service .



.NET Development13  
 
 
RomanGuzi





PostPosted: .NET Remoting and Runtime Serialization, Remoting event. Top

I experienced the same problem and I was unable to send event from windows service. Being run out of time I resolved it by registering event listener on a server. So that each client register its own event listener on server and unregister when terminating. Something like this:

class Server

{

private EventListener _listener;//actually I put array of listeners here

public void RegisterListener(EventListener listener)

{

_listener = listener;

}

protected void SendEvent()

{

if (_listener != null)

{

try

{

_listener.InvokeEvent();

}

catch

{

}

}

}

}

class EventListener //created on a client

{

public InvokeEvent()

{

//Invoke delegate on a client side here

}

}



 
 
Parwej Ahamad





PostPosted: .NET Remoting and Runtime Serialization, Remoting event. Top

Thanx RomanGuzi,

First one is i have use vb.net,
i have implement below remote object.

Public Delegate Sub MagicNumberCallback(ByVal UsersList As ArrayList)

Public Interface ICalc
ReadOnly Property AppDomainName() As String
Event MagicNumber As MagicNumberCallback
Function Login(ByVal Server As String, ByVal UserName As String, ByVal Password As String)
Function Find(ByVal Keyword As String)
End Interface

<Serializable()> _
Public Class EventShim
Inherits MarshalByRefObject

Private target As MagicNumberCallback

Private Sub New(ByVal target As MagicNumberCallback)
MyBase.New()
Me.target = target
End Sub

Public Sub MagicNumberShim(ByVal UserList As ArrayList)
target(UserList)
End Sub

Public Shared Function Create(ByVal target As MagicNumberCallback) As MagicNumberCallback
Dim shim As EventShim = New EventShim(target)
Return New MagicNumberCallback(AddressOf shim.MagicNumberShim)
End Function
End Class

It's working well without window service,
but in service

Login() method running well,
when we going to Find()........user
it's not work bcz Find() method generate an event on basis of find successfull or not.

 
 
RomanGuzi





PostPosted: .NET Remoting and Runtime Serialization, Remoting event. Top

Why not to return result (successfull or not) directly by Find() method

I mean:

bool findResult = remoteObject.Find(userName);

As I told previously, I was not able to send event from windows service too. So I was forced to redesign my application by providing server with MBR object created on a client. You can follow me or you can wait while somebody explains how to send events (I am also waiting for that).



 
 
Parwej Ahamad





PostPosted: .NET Remoting and Runtime Serialization, Remoting event. Top

Thanx RomanGuzi,

You r right but problem is that .....
Find() method not directly find the result. It's also wait an event from the other server.

After generate the event by the other then it's generate event for remote client.

Plz Help.






 
 
Jesus Ruiz - MSFT





PostPosted: .NET Remoting and Runtime Serialization, Remoting event. Top

Do you have any diagnostics information for the Windows Service Do you know if an exception is being thrown when firing the event Is there anything in the EventLog