Start AutoCAD with interop, but with different user

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I'm pretty sure, that this question is not for this forum, since it is not for plugins. But this is the closest to .NET, so please pardon me for posting here.
I need to start AutoCAD from a windows service. This service is running with a "special" domain user, which is created for just running my service. This user is admin on the machine, and this user installed AutoCAD 2014 on the machine. The code I'm using to start AutoCAD 2014 from C#:
IAcadApplication acadApp; try { var acadType = Type.GetTypeFromProgID("AutoCAD.Application.19", true); acadApp = (AcadApplication) Activator.CreateInstance(acadType, true); } catch (Exception ex) { // do fancy error handling here }
I have a reference to the AutoCAD COM library. (Interop.AutoCAD.dll) If I run the above code with my logged in user, AutoCAD starts and I can do anything I want with SendCommand. If I put it in a service, start the service with my "special" user the CreateInstance command throws this:
{"Retrieving the COM class factory for component with CLSID {BD0DEB94-63DB-4392-9420-6EEE05094B1F} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))."}
The thing is, that acad.exe starts, but stops consuming memory around 44 MBytes, and after 1-2 minutes, I get the exception. Usually, acad.exe starts with 112 MByte of memory consumed. If I run the service in the logged in user's name, everything works as expected. Both users are in the same user groups, same domain. So my code is essentially works. But the goal is, to have a server program, that can run AutoCAD stuff. How can I run AutoCAD on a server in this scenario? According to some posts around the net, this can be caused by access rights problems. But what rights do I have to give to the "special" user?
Tahnks,
Gyula