I have a Windows service written in c# which keeps listening to one Event Hub in Azure. As soon as a message is received, the service processes the message and does some execution and calculation.
As part of the execution, it launches a application called AutoCal (company's own window's application), which is COM component similar to that of Excel.
Earlier I had a web api which does the same calculation/execution. Upon every request it opens AutoCal and does some processing. I have added the AutoCal DLL as reference in the project.
The code to open AutoCal is something similar:
(AutoCal.Application)Interaction.CreateObject("AutoCal.Application.NewInstance").
When I tested this locally, it has perfectly as expected. But once I hosted this on the server, it has thrown an error saying "Cannot create ActiveX component". To rectify this, I have given permission to open COM components to Application Pool of IIS. This has resolved my issue.
Now that I have a windows service which also open the AutoCal, from where do I give CO component permissions. I have searched for it, but everywhere the solution is for ASP.net only.
How can I rectify this issue for Windows service?
PS: When I have written same code in console application, it is working fine.
Without having exact error logs (can you try looking for related errors in the EventViewer?) it's hard to tell what the problem is.
But I would try the following:
Component services and open it (right click - as admin!)Component services -> My Computer -> DCOM Config folderYou'll see something like this

Security TabIt will look like this (never mind the title of the tab in the picture, in your case it should be something like AutoCal):

If it's grayed out, like in my case, you can use the following procedure to change the settings on your system, and make this tab configurable:
Start > Run. Enter regeditHKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} PermissionsAdvancedAdministrator or your user accountOKFull Control for the Administrators group and owner you selectedStart > Run. Search for services.
Find COM+ System Application. Right click on the service, then click Restart
Once you have the Security tab enabled, you can change the permissions for your COM object. For example - you can allow the user, under which your service runs, to access or activate this COM object.
I hope this helps you, but again, without any additional error info - it's a long shot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With