[英]C# Microsoft.Office.Interop.Outlook launch from Windows Service
I'm using the Microsoft.Office.Interop.Outlook
to do the following:- 我正在使用
Microsoft.Office.Interop.Outlook
执行以下操作:
All the above points are working perfectly fine if I run my C# console application manually. 如果我手动运行C#控制台应用程序,以上所有这些都可以正常工作。 It also works sometimes when I launch the console application from Windows Service.
当我从Windows Service启动控制台应用程序时,有时也可以使用。 But some times not.
但是有时候没有。 I read somewhere in Stack that
Microsoft.Office.Interop.Outlook
is not designed for Windows Services. 我在Stack的某个地方读到
Microsoft.Office.Interop.Outlook
不是为Windows Services设计的。
What is the best method (quick and fast to develop) to all the above task from Windows Service? 通过Windows Service完成上述所有任务的最佳方法(快速,快速开发)是什么?
What is the best method (quick and fast to develop) to all the above task from Windows Service ?
从Windows Service完成上述所有任务的最佳方法(快速,快速开发)是什么?
Short answer - you can't. 简短答案- 您不能。
COM Automation servers such as the ones from Microsoft Office are GUI-based and therefore require a message pump . COM Automation服务器(例如Microsoft Office的服务器)是基于GUI的,因此需要消息泵 。 When you consider that Windows Services typically run prior to a user logging in, it's not possible to launch a process that attempts to show a GUI.
如果您认为Windows服务通常在用户登录之前运行,则无法启动尝试显示GUI的进程。 It would simply lock-up.
它只会锁定。
One could argue that you could always wait until the user logs into Windows but then it sort of defeats the purpose of windows services - that user login is not necessary. 有人可能会争辩说,您总是可以等到用户登录Windows时,才可能违反Windows服务的目的-不需要用户登录。 Plus if Windows were to reboot your app would not run until the user logs in again.
另外,如果Windows要重新启动,您的应用程序将在用户再次登录后才能运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.