Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 518

Using Apprentice from a Windows Service

$
0
0

By Adam Nagy

First of all, we have to clarify that using Apprentice or Inventor from a Windows Service is not supported. So if you really get into issues with it for one reason or another then we cannot help you.

If you still decide to give it a try then keep on reading. 

Some info on creating a .NET Windows Service and debugging it:
Walkthrough: Creating a Windows Service Application in the Component Designer
- How to: Add Installers to Your Service Application 
How to: Debug Windows Service Applications  

For testing purposes I created a service that monitors a given folder for ipt files being moved to it. If an ipt file shows up then the service retrieves the Summary Information iProperties from the document and appends that to a log file residing in the same folder that is being monitored: https://github.com/adamenagy/ApprenticeFromWindowsService

If you created a Windows Service and it uses Local System account then it will try to get the registry keys from the HKLM (Local Machine) part of the registry which does not include information about all the Inventor COM objects. Therefore creating the ApprenticeServerComponent will fail with message "Retrieving the COM class factory for component with CLSID {C343ED84-A129-11D3-B799-0060B0F159EF} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

Error 

There could be a couple of solutions:
1) Run the service under a user account:

UserAccount

In the video you can see that after starting the service from the admin account the service is functional even from a Guest account: https://www.youtube.com/watch?v=Zh9pY0u3dsQ 

2) Copy all the Inventor COM object entries from the HKCU (Current User) section of the registry to the HKLM (Local Machine) one. This might be risky as modifying registry entries usually can be. So make sure you know what you are doing: https://github.com/adamenagy/RegistryCopy 

Here is also a video showing how copying the registry entries from HKCU to HKLM solves the problem: https://www.youtube.com/watch?v=bqcIcspnwuQ

3) Don't use a Windows Service for this. :)

 


Viewing all articles
Browse latest Browse all 518

Trending Articles