Help!! Problem instantiating WORD object using C#.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi experts,

I am trying to open the content of a WORD file from C#.NET which resides in
the REMOTE SERVER, however I get an error:
"System.Runtime.InteropServices.COMException: Server execution failed"
when declaring new Word.ApplicationClass().

string fileName = this.btnWorkOrder1.Value;
object readOnly = false;
object isVisible = false;
object saveChanges = false;
object missing = System.Reflection.Missing.Value;
object dynamic = 2;

//error here:
Word.ApplicationClass oWordApp = new Word.ApplicationClass();

Word.Document oWordDoc = oWordApp.Documents.Open(ref file, ref missing, ref
readOnly, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing,
ref missing, ref missing, ref isVisible);


Does anybody know how to solve it? Please help!!!

Thanks alot!!!


Handy Mulia
 
Hi Handy,

If you're doing this from an ASP.NET application the most likely culprit is
security as the NETWORK SERVICE or ASPNET account which typically run
ASP.NET applications doesn't have rights to either execute a remote object
or open a file on a remote server.

To fix you will either have to give these accounts special rights in
DCOMCNFG with the Word object, or else you have to use Impersonation in your
application to elevate rights.

Here are a couple of WebLog entries that might help:

http://west-wind.com/weblog/posts/2153.aspx
http://west-wind.com/weblog/posts/1572.aspx


+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
 
Back
Top