I'm using the Microsoft.Office.Interop.Outlook
to do the following:-
All the above points are working perfectly fine if I run my C# console application manually. It also works sometimes when I launch the console application from Windows Service. But some times not. I read somewhere in Stack that Microsoft.Office.Interop.Outlook
is not designed for Windows Services.
What is the best method (quick and fast to develop) to all the above task from Windows Service?
What is the best method (quick and fast to develop) to all the above task from 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 . 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. 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. Plus if Windows were to reboot your app would not run until the user logs in again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.