Creating Microsoft Word Object in Thread Fails on Deployed Workstation

I am running some office automation in a thread.  This works on my development machines, but fails when deployed.  If I run the same code outside of a thread, it works on all machines.  Does anyone have any ideas?  I became so frustrated that I created the most basic non-class driven automation to make sure I wasn't going crazy:

Attached are two files, same program but one calling via thread the other direct.


Who is Participating?
Anurag ThakurConnect With a Mentor Technical ManagerCommented:
logged in users normally have higher permissions as they can create files etc on the PC when logged on.
Office.Dll should have been there in your working directory (in the references you might have not selected copy local for the reference) thats why its missing when you deploy it
It will work perfectly well on development because it knows from which path the reference has been added but on deployment machine the local copy is needed to make it run. Thats my observation and adding more i dont think that there are any specific rules for threads as a normal execution exe
Anurag ThakurTechnical ManagerCommented:
The first reason that comes to my mind in such a scenario when something works on development machine and not on deployment machine is the permissions of user under whose credentials the code/application is running under

generally on dev machines we always have admin rights and when we deploy the user credentials the application is using is generally restricted
DuBoisCGAuthor Commented:
It's a good thought, but the working test (same code, just not in a thread) runs as the local user.

I actually got it working by adding the office.dll into the working directory, but want to leave this issue open to see if anyone can explain why this dll wasn't required for the working test.  If there are some important rules for threads that limit their ability to access resources, it would be nice to document it here (couldn't find much threaded function help).
DuBoisCGAuthor Commented:
We still don't know why the same code would run outside a thread on the same machine as the same user... but ultimately it needed the referenced dll in the working directory in order for the thread version to run.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.