{"The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"}

O

Omatase

I have an app that manipulates word docs. I have some code that adds
tables to a document. I have been working on this application for
about a month now and all of a sudden every doc that I attempt to run
my code on throws the error in the subject line. Over the course of
the month I have seen this error intermittently but since last night
it happens on every doc. If I go back 3 weeks and get a version of the
program that never experienced this problem in the past it is
experiencing it today. This leads me to beleive it's not the code, but
I would still appreciate any comments on the code I can get.

Here is what the code looks like that is having the problem:

Document aDoc = _wordApplicationInstance.Documents.Open(ref
letterPathAndFile, ref missingValue, ref falseValue, ref falseValue,
ref missingValue, ref missingValue,
ref missingValue, ref
missingValue, ref missingValue, ref missingValue, ref missingValue,
ref falseValue);

try
{
// field codes have to be on for this portion of the searching
to work
aDoc.ActiveWindow.View.ShowFieldCodes = true;

// track revisions has to be off or it messes up the logic
aDoc.TrackRevisions = false;

// if found, we know where our start point is now for
inserting our table
// if we didn't find it we don't have our starting point and
if that is
// the case we cannot continue.
if (beginning.Find.Found)
{
object start = 1;

object autofitBehavior =
WdAutoFitBehavior.wdAutoFitContent;

Table theTable;

try
{
//object missingValue =
System.Reflection.Missing.Value;

// put our table here
Range tableLocation = aDoc.Range(ref start, ref
start);
int columns = 3;
int rows = 1;
theTable = aDoc.Tables.Add(tableLocation, rows,
columns, ref missingValue, ref autofitBehavior);

formatTable(theTable);
........


private void formatTable(Table theTable)
{
theTable.LeftPadding = 0.0f;
theTable.RightPadding = 0.0f;

// eliminate table borders
theTable.Borders.Enable = 0;
theTable.Borders.Item(WdBorderType.wdBorderBottom).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderDiagonalDown).LineStyle
= WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderDiagonalUp).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderHorizontal).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderLeft).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderRight).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderTop).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.Item(WdBorderType.wdBorderVertical).LineStyle =
WdLineStyle.wdLineStyleNone;
theTable.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleNone;
theTable.Borders.InsideLineStyle = WdLineStyle.wdLineStyleNone;


theTable.Columns.Item(1).SetWidth(_wordApplicationInstance.InchesToPoints(4.50f),
WdRulerStyle.wdAdjustNone);

theTable.Columns.Item(2).SetWidth(_wordApplicationInstance.InchesToPoints(1.14f),
WdRulerStyle.wdAdjustNone);

theTable.Columns.Item(3).SetWidth(_wordApplicationInstance.InchesToPoints(1.14f),
WdRulerStyle.wdAdjustNone);

theTable.Cell(1, 1).VerticalAlignment =
WdCellVerticalAlignment.wdCellAlignVerticalBottom;
theTable.Cell(1, 2).VerticalAlignment =
WdCellVerticalAlignment.wdCellAlignVerticalBottom;
theTable.Cell(1, 3).VerticalAlignment =
WdCellVerticalAlignment.wdCellAlignVerticalBottom;

theTable.Cell(1, 2).RightPadding = .5f;//
_wordApplicationInstance.InchesToPoints(.50f);
}

the error occurrs on the following line:

theTable.LeftPadding = 0.0f;

The stack trace looks like this:

" at Word.Table.set_LeftPadding(Single prop)\r\n at
formatTable(Table theTable) in C:\\DocUpdate.cs:line 514\r\n at
updateLetter(Object letterPathAndFile, String directory) in C:\
\DocUpdate.cs:line 335"

It's written in c# and I know that this is the word.vba group but
there was no word.csharp group and this seemed more appropriate than a
non-word group as I think it's a problem in the word object model that
I'm experiencing.

(I've rebooted several times to no avail)
 
O

Omatase

I want to amend this. I can't rule out that the code is bad now where
it wasn't before. I found an old compiled copy of the same application
and it works fine.

Any help is appreciated.
 
O

Omatase

I made an interesting discovery. If I put a Thread.Sleep(50) command
in between each action I take on the table the error doesn't occur.
Does anyone have any ideas as to why this could be happening now from
out of the blue? I have just uninstalled and reinstalled office to see
if that makes a difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top