C# 事件不';无法获得命中WCF服务实现

C# 事件不';无法获得命中WCF服务实现,c#,wcf,event-handling,servicecontract,C#,Wcf,Event Handling,Servicecontract,我有一个WCF服务接口、一个实现契约的类和一个托管winforms应用程序。然后,这将启动连接回WCF服务器的工作进程,然后触发事件。客户端工作进程在调用方法时没有任何问题,我希望附加的事件处理程序也能在Windows窗体应用程序中调用,但这不会发生: xWCFService xWCFService = new xWCFService(); xWCFService.eventWorkerProcessStart +=

我有一个WCF服务接口、一个实现契约的类和一个托管winforms应用程序。然后,这将启动连接回WCF服务器的工作进程,然后触发事件。客户端工作进程在调用方法时没有任何问题,我希望附加的事件处理程序也能在Windows窗体应用程序中调用,但这不会发生:

                    xWCFService xWCFService = new xWCFService();
                    xWCFService.eventWorkerProcessStart += new EventHandler<WorkerProcessProgressChangedEventArgs>(xWCFService_eventWorkerProcessStart);
                    xWCFService.eventWorkerProcessStop += new EventHandler<WorkerProcessProgressChangedEventArgs>(xWCFService_eventWorkerProcessStop);
                    xWCFService.eventWorkerProcessUpdateProgress += new EventHandler<WorkerProcessProgressChangedEventArgs>(xWCFService_eventWorkerProcessUpdateProgress);
                    xWCFService.eventWorkerProcessError += new EventHandler<WorkerProcessProgressChangedEventArgs>(xWCFService_eventWorkerProcessError);


                    ServiceHost xServiceHost = new ServiceHost(xWCFService, new Uri(serviceAddress));

                    xServiceHost.AddServiceEndpoint(typeof(IxWCFServiceContract), new NetTcpBinding(), address);
                    xServiceHost.Open();
xWCFService xWCFService=newxwcfservice();
xWCFService.eventWorkerProcessStart+=新的事件处理程序(xWCFService\u eventWorkerProcessStart);
xWCFService.eventWorkerProcessStop+=新的事件处理程序(xWCFService\u eventWorkerProcessStop);
xWCFService.eventWorkerProcessUpdateProgress+=新事件处理程序(xWCFService\u eventWorkerProcessUpdateProgress);
xWCFService.eventWorkerProcessError+=新的EventHandler(xWCFService\u eventWorkerProcessError);
ServiceHost xServiceHost=新ServiceHost(xWCFService,新Uri(serviceAddress));
AddServiceEndpoint(typeof(IxWCFServiceContract),新的NetTcpBinding(),地址);
xServiceHost.Open();

我将服务类的实例传递给servicehost,它是一个单实例。我非常感谢您提供的任何帮助/见解,说明我为什么没有引用正确的实例。

经过大量阅读,我注意到客户端代码中的错误:

            static xWCFService xwcfService = new xWCFService();

           ....
       {
            EndpointAddress endPoint = new EndpointAddress(new Uri(string.Format(xWCFServerBaseAddress, address) + address));
            Binding binding = new NetTcpBinding();
            xChannelFactory = new ChannelFactory<IxWCFServiceChannel>(binding, endPoint);
            xChannelFactory.Open();
            xServiceChannel = xChannelFactory.CreateChannel();
            xServiceChannel.Open();

            **xwcfService.WorkerProcessStartedParsing(strGuidClientIdentifier);**
static xWCFService xWCFService=new xWCFService();
....
{
EndpointAddressEndpoint=新的EndpointAddress(新Uri(string.Format(xWCFServerBaseAddress,address)+address));
Binding Binding=新的NetTcpBinding();
xChannelFactory=新的ChannelFactory(绑定,端点);
xChannelFactory.Open();
xServiceChannel=xChannelFactory.CreateChannel();
xServiceChannel.Open();
**WorkerProcessStartedParsing(strGuidClientIdentifier)**
最后一行是我的错误,我是通过服务实现类的实例调用服务调用的。当我使用xServiceChannel调用服务上的方法时,引发了所有事件