3

I have a problem with a C# .NET command line application, which main idea is to get data from other program using COM object. It works fine when being executed manually or when running as a child process inside Node.js server, however when the entire project is installed as a windows service the C# app responds with following error:

System.UnauthorizedAccessException: Creating an instance of the COM component with CLSID {D64DB4A9-3B26-4D2B-B556-9DA433C54175} from the IClassFactory failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at CurrentCamUri.Program.Main(String[] args)

From what I read here and on similar threads mainly focused on Office applications, I should see the COM object inside "DCOM Config" tab in dcomcnfg /32, however I can't find anything with the related CLSID. I tried running dcomcnfg without the '/32' suffix but also with no success. The main application with which I need to get data from is 32-bit (let's call it mother app).

Any suggestion how can I approach that problem? I would be really grateful. Thanks!

Community
  • 1
  • 1
k0ff33
  • 311
  • 1
  • 12

1 Answers1

1

Ensure that the Windows Service is running under an account that has permissions to access the COM component.

You can check these permissions by starting regedt32.exe, going to HKCR\CLSID{D64DB4A9-3B26-4D2B-B556-9DA433C54175}, right click and choose "Permissions...".

Miner_Glitch
  • 537
  • 4
  • 16
  • Thanks for reply. I tried regedt32.exe, but there's nothing under HKCR\CLSID{D64DB4A9....}, however after using search I found that this CLSID is under HKCR\ControlCenter.Automation\CLSID. Modyfing the "Permissions" to allow full control on my local user and setting the Windows Service to "log on" the same user still does not the trick, same error. – k0ff33 Oct 04 '15 at 00:04
  • If it's not under HKCR\CLSID\{D64DB4A9....}, try checking under HKLM\Software\Wow6432Node\Classes. – Miner_Glitch Oct 04 '15 at 01:06
  • I found it under HKLM\Software\Wow6432Node\Classes\CLSID\{64DB4A9...}, permissions seems to be fine (full access on administrators/users), I tried adding my username with full control just in case but it's still not working. I wonder if the problem may be in my C# application in handling the COM? I'm not a C# developer on every-day basis. – k0ff33 Oct 04 '15 at 11:48
  • Is there also an entry for it under HKLM\Software\Wow6432Node\Classes\AppID\{64DB4A9...} ? If so, check the launch permission as per https://msdn.microsoft.com/en-us/library/ms687202(v=vs.85).aspx – Miner_Glitch Oct 04 '15 at 12:07
  • Sorry, in previous comment I missed D at front of the CLSID. There's no such an entry as HKLM\Software\Wow6432Node\Classes\AppID\{D64DB4A9...}. – k0ff33 Oct 04 '15 at 12:39
  • Go and check that page http://stackoverflow.com/questions/1491123/system-unauthorizedaccessexception-retrieving-the-com-class-factory-for-word-in again, but follow the instructions given by sliderhouserules . This should hopefully create the AppID entry, which you need to solve your issue. See here: http://blogs.msdn.com/b/jigarme/archive/2007/10/09/what-is-appid.aspx for an explanation. – Miner_Glitch Oct 04 '15 at 12:48
  • Thanks, that did the trick! Just for reference, I followed sliderhouserules guide, the application was displayed in the DCOM Config tab (not named as {D64DB4A9...} but with specific name - it's easy to swap to detailed view with CLSIDs along with names) and then it was just a matter of changing the Identity Properties to run as "interactive user". – k0ff33 Oct 04 '15 at 13:55