AfxConnectionAdvise(AtlAdvise)事件接收器无法在Windows服务中运行 [英] AfxConnectionAdvise (AtlAdvise) event sinks not working in a Windows Service

查看:218
本文介绍了AfxConnectionAdvise(AtlAdvise)事件接收器无法在Windows服务中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++  windows应用程序,其中包含一个DLL,它使用AfxConnectionAdvise将事件接收器连接到从COM库公开的IDispatchEvents接口。一切都很好。现在,我已将此
应用程序的业务逻辑移植到基于CServiceBase的Windows服务应用程序中。由于该服务没有主窗口,因此我在主工作线程中包含了一个消息泵,主要用于获取套接字事件。在所有方面,这项服务都会做它应该做的一切,
除了事件接收器事件永远不会被解雇。对AfxConnectionAdvise的调用在服务中返回true。我用AtlAdvise替换了AfxConnectionAdvise并返回S_OK。因此看起来水槽正在制造,但是,我的水槽事件永远不会被调用。
我试过单步执行COM库以查看它是否正在调用接收器事件,它似乎正在这样做;没有异常被抛出。但是,我的服务从未通知。我想我没有设置正确的东西,但我还没有能够b $ b来弄清楚是什么。有没有其他人遇到这个,如果是这样,你是如何解决它的?

I have a C++ windows application which includes a DLL that uses AfxConnectionAdvise to connect an event sink to an IDispatchEvents interface exposed from a COM library. Everything works great. Now, I have ported the business logic of this application into a windows service application based on CServiceBase. Since the service doesn't have a main window, I included a message pump in my main worker thread, primarily to get socket events. In all respects, this service does everything it should, except the event sink events never get fired. The call to AfxConnectionAdvise returns true in the service. I replaced AfxConnectionAdvise with AtlAdvise and it returns S_OK. So it appears that the sink is getting made, however, my sink events never get called. I have tried stepping through the COM library to see if it is calling the sink events and it appears to be doing so; no exceptions are thrown. However, my service is never notified. I think I don't have something set up correctly, but I have not been able to figure out what. Has anyone else run into this, and if so, how did you resolve it?

推荐答案

想到几个想法 -

A couple of thoughts come to mind --

是否已注册所需的代理/存根dll?

Have any needed proxy/stub dlls been registered?

Windows服务似乎是COM客户端。 如果是这样,托管COM服务器的进程是否有足够的权限在事件被触发时调用Windows服务?

It seems the that Windows service is the COM client.  If so, does the process hosting the COM server have adequate permissions to call into the Windows service when events are fired?


这篇关于AfxConnectionAdvise(AtlAdvise)事件接收器无法在Windows服务中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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