从客户端(WCF)调用时,引发事件不会在主机服务中触发 [英] Raise event doesnt fire in host service when called from client (WCF)

查看:170
本文介绍了从客户端(WCF)调用时,引发事件不会在主机服务中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个事件,该事件从客户端引发时没有引发.寻求解决方案已经好几天了,没有任何运气...

我不知道这是WCF问题还是一般的VB.net问题.也许是线程问题?

完全没有错误消息.

I have a problem with event that doesnt raise when its raised from client. Searshed for a solution for days now without any luck...

I dont know if its a WCF problem or a general VB.net problem. Maybe threading problem?

No error messages at all.

'My WCF service class
   Public Class LogProLiveCommunication
    Implements ILogProLiveCommunication

    Public Event Test(ByVal sender As System.Object, ByVal e As System.EventArgs)

   'This function is called by the WCF client and works ok except from the raise event Test!?!
    Public Function ConnectToLogProLive(ByVal clientName As String, ByVal clientIP As String) As String Implements ILogProLiveCommunication.ConnectToLogProLive
        MsgBox("Client Connected: " & clientName & " IP: " & clientIP)
        Debug.Write("Service: RaiseEvent Client Connected: " & clientName & " IP: " & clientIP) 'This works
        RaiseEvent Test(Me, New EventArgs) 'This doesnt work
        Return "Ok" 'Works
    End Function

    Public Sub raiseEventTest()
        RaiseEvent Test(Me, New EventArgs) 'This one is fired ok
    End Sub

End Class

推荐答案

也许正在引发该事件,但您尚未在其上设置侦听器,即在注册侦听器之前正在调用ConnectToLogProLive.
Maybe the event is being raised but you haven''t set a listener on it yet, ie ConnectToLogProLive is being called before you have registered your listener.


这篇关于从客户端(WCF)调用时,引发事件不会在主机服务中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆