I have some code running in a C# console application that has no problems until I install the application as a service and run it that way.
I am using "Method 2" from ModTheMachine's post here: http://modthemachine.typepad.com/my_weblog/2009/01
As stated, the code runs fine if I manually execute the application but if I install it as a Windows Service and start it, I get a failure on the SaveAs line. Everything else runs fine.
The Inventor.Application.Visible setting is false and the Inventor.Application.SilentOperation is true in both scenarios.
Here is the error I receive:
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
Solved! Go to Solution.
Please check your source code with regards to all operations that are user specific, I mean user directories etc are different in case of a service vs.exe. Also you might have permission issues, since you are not logged in like a desktop/terminal user.
This answer is pretty common but I hope it helps either.
Those are helpful suggestions but this is definitely not a permissions issue, as I am running the Service with my same user that I am logged into Windows with. I can tell through debugging that the I get a consistent error on the SaveAs line of code when I am running as a service.
I am still having this issue.
I am also having this issue. It seems that Inventor requires a visible drawing screen to actually save as or even do a plot from the printmanager object (to PDFCreator or AdobePDF). Everything works fine when it's outside the service if inventor is a visible application.
And (as a service...not the local admin), I modified the registery to allow that user to "interact with the desktop". This had the same results.
Check to make sure you are supplying a absolute (or full) path name for the file. Services may not started from the same directory versus just run normally so you need to make sure you're not using path names that are relative.
I appreciate the suggestion but I am definitely using a full local path as my SaveAs parameter. It's something like "C:\LocalFolder\FileName.pdf"
What i'm finding out as a difference between the service and running as a console app, is that there are a few differences, but the main ones i believe are causing the problems are:
application.ActiveView is null
the VisibleDocument list count is 0
If you know of a way to set an activeview or force a document visible, let me know
I am trying to set plot or save the entire assembly to a pdf (and eventually dxf or other formats)
Just to let you know that un-hidding this view this made everything work.
It's pretty nice, we have a box that runs this service, grabs parameters from a database, loads the correct assembly and generates the drawings according to specs, does this all from a web page submission.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register