是否可以在Windows服务中使用API [英] Is it possible to use API in Windows service

查看:206
本文介绍了是否可以在Windows服务中使用API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从Windows服务在C#.NET中从CommunicatorAPI创建Messenger实例?

我正在尝试编写一些与登录用户的存在相关联的简单Windows服务。

现在,我可以从C#控制台应用程序实例化,但不能从Windows服务实例化。我收到此错误:

由于以下错误,检索具有CLSID {8885370D-B33E-44B7-875D-28E403CF9270}的组件的COM类工厂失败:80080005。

解决方案

我认为你不能做到这一点。 Communicator API由正在运行的Communicator(OC)进程本身实现。这就是为什么在使用自动化API之前必须运行Communicator的原因。由于OC进程未在与服务相同的用户上下文中运行,因此无法访问自动化API。并且您无法在服务的上下文中启动OC,因为服务没有"桌面"服务。执行时的上下文。

我认为你的选择是:



  • 使用服务中的CWA AJAX API如果您有支持该服务器的CWA 2007服务器。

  • 使用UCMA API编写您自己的Web服务并从您的服务中调用它。

  • 使用服务中的UCC客户端API连接到OCS并查询用户的存在。


在所有这些情况下,您需要确保维护应用程序的安全性和隐私性。您的服务需要使用一些用户凭据才能访问OCS,并且您需要确保用户上下文可以看到您要使用的状态信息。





Is it possible to create an instance of Messenger from CommunicatorAPI in C#.NET from a Windows Service?

I'm trying to write some simple windows service tied to the presence of the logged in user.

Right now, I'm able to instantiate from a C# console application, but not from a Windows service. I'm getting this error:

Retrieving the COM class factory for component with CLSID {8885370D-B33E-44B7-875D-28E403CF9270} failed due to the following error: 80080005.

解决方案

I don't think that you can make this work.  The Communicator API is implemented by the running Communicator (OC) process itself.  That's why Communicator has to be running before you can use the automation API.  Since the OC process is not running in the same user context as your service, it can not access the automation API.  And you can't start OC in the context of a service since a service does not have a "desktop" context when it executes.

I think that your options are:

  • Use the CWA AJAX API from your service if you have a CWA 2007 server to support that.
  • Write your own web service using the UCMA API and call that from your service.
  • Use the UCC client API in the service to connect to OCS and query for the presence of the user.
In all these cases you will need to make sure that you maintain security and privacy for the app.  Your service will need to use some user credentials to access OCS and you need to make sure that user context can see the presence information that you want to use.

 



这篇关于是否可以在Windows服务中使用API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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