.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Start AutoCAD with interop, but with different user

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
1750 Views, 6 Replies

Start AutoCAD with interop, but with different user

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

 

Stackoverflow

Tags (1)
6 REPLIES 6
Message 2 of 7
SRayC
in reply to: Anonymous

I have run into similar issues using ACAD as a COM object. Here are some things that could be getting in the way.

 

If you are running Autodesk's License Manager to delve out shared license's, be sure your "special user" is in the valid users list. Adding FLEXLM_TIMEOUT to your environment variable with a few seconds delay may help also.

 

Another thing is Autodesk's Communication Center sometimes causes a delay. This can be disabled through the registry. Search for InfoCenterOn and set the value to 0

(Be sure to do a backup first)

 

Hope this helps.

 

Ray C.

Message 3 of 7
SRayC
in reply to: SRayC

I fogot the most important one. See this post.
http://through-the-interface.typepad.com/through_the_interface/visual_basic/

Ray C.
Message 4 of 7
Anonymous
in reply to: SRayC

Hi Ray C.!

 

We are not using License Manager. AutoCAD is installed on the computer, and any logged in user can run it.

I've turned off InofCenterOn, but nosuccess.

 

On the other hand, I was wrong describing my problem. I just found out, that I can not start AutoCAD from a windows service, no matter which user I'm starting the service with. (BTW, the service is a WCF Host...) So, either using my own user, or the "special user" to start the service, it can't start AutoCAD. Since the code is in a class library, I can call it directly, without a service: in this case, the same code runs, no matter which user I'm logged in with.

My problem with this "solution" (calling it directly), that my service is using a parallel queue, running multiple tasks. And one step of this task would be to start AutoCAD, wait for a LISP program to finish, and continue with the next step. The service is called from an ASP.NET Web project.

 

Thanks for your suggestions.

Gyula

Message 5 of 7
owenwengerd
in reply to: Anonymous

I don't think the standard EULA allows running AutoCAD as a service, so it may be that AutoCAD is explicitly designed to fail at startup when started from a service.

--
Owen Wengerd
ManuSoft
Message 6 of 7
t.deflers
in reply to: Anonymous

Hi, i'm having the same problem as you.

 

We started encountering the problem since Windows Vista and a few years ago i worked a few weeks on the problem without finding a solution. Problem was in theory, escalated to AutoCAD developers.

 

Until then, we were telling the customers to always have a console session opened on the machine and run the component in a COM+ application which identity was set to "Interactive User". This was working pretty good before Windows Vista. Until then, for the machine to be always functional, you could tell Windows to automatically start a session with a specified user.

 

The problem is coming back to us from a customer who absolutely don't wan't this automatic Windows Session opening mechanism. So i went back to work... it's been 2 weeks now and i think i've made some little progress.

 

First you have to understand the Session 0 isolation that appeared in Windows Vista and superior (google is your friend). And all the mechanism with Session, Windows Stations and Desktops. It is not possible to create the interactive desktop (WinSta0\default) under session 0. I tried to emulate the behavior of working in an interactive session for AutoCAD to think it's working on the real desktop.

 

Here is the things i did to "try" to make it work:

- having a Windows user fully working with AutoCAD.

- Set up your components or service to start with this specific user

- Load the user profile (user registry hive is not loaded from services or COM+)

- Create the Windows desktop

- Impersonate the user credentials (no sure for this one)

- Implements a MessageFilter loop (mandatory, not related to Windows, AutoCAD 2010 and +)

- Start AutoCAD using different techniques (still working on this one)

 

Something like Process.Start() and GetObject() seems to behave better that any of the CreateObject or New autodesk.AutoCAD.application() i've tried.

I manage to make it work on a developement machine but not on other VMs i have.

I'm really not sure i will succeed one day but let's hope so 🙂

 

Sorry if this goes against some of the EULA rules but i'm just trying to find a technical answer (i think the commercial issues can be discussed later with the good people)

However if we could have some sort of "official" answer from Autodesk to this problem (i.e. not supported for example), we would have something to reply to our customer.

 

Thibault

Message 7 of 7
Anonymous
in reply to: t.deflers

Hi Thibault!

 

Thank you for your detailed answer. It is good news, that there is hope. ("There is light at the end if the tunnel. But why does it honk?")

Currently I don't have the resources (time) to work on this, but when I'll have, I'll pick up your ideas, and try to implement them. Unless you find a solution earlier and share it with the public. 🙂

 

Regards,

Gyula

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost