Windows Service - Automation Error

  • Thread starter Thread starter THNQDigital
  • Start date Start date
T

THNQDigital

Hi All,
I have written VB.NET Windows Service whcih reads some
information from Outlook and creates an Excel report outa
it.

When i make a console application and run the program
everything works fine but same code does not work if i put
it in an Windows service.

My OS : Win2000 Pro

Error is thrown where create object of Outlook ( VB6.0)
Set objOutlook = CreateObject("Outlook.Application")
Can not create Activex Object ( if i run as an exe it
works fine but if i make it as an NTService it throws this
error)

Error is thrown where i say ( VB.NET Win Service)

Public oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
Dim oInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox)

System.Runtime.InteropServices.COMException (0x84140102):
Could not complete the operation because the service
provider does not support it

Is this a bug of MS or is there any fix available?
Please let me know

Best Regards
THNQDigital
 
While I do not do much Office programming, I would suspect that if you
set the service user to allow to interact with the desktop, you would
find that the error goes away.

HTH

David
 
Hi David,

Thanks for the reply.
I found the problem with the service in VB6.0
I had to run the code under Sub Main()( Installation) in a
module Plus i placed all the code that actually creates
the object of the DLL whcih creates objects of Office (
Outlook, Excel) in a module , instead i was running the
code under Form_Load() and other procs whcih create
outlook objects in teh form class only.

But in VB.NET i tried your suggestion to run the service
with User name who has Admin access to the system. But
still the same error..

Best regards
THNQ Digital
 
It is not just Admin rights that your service will need. Set the user
to Local System (which has Admin rights on the system only), and check
the "Allow service to interact with the desktop" option.

HTH

David
 
Back
Top