M
MarkusHedlund
Guest
We’re using Microsoft.Office.Interop.Word to update values in a Word template from C# from a desktop application.
The implementation loops over a dictionary with bookmarks as keys and texts as values. For each entry in the dictionary the following method is used to set the text.
public void SetFormFieldText(string name, string text)
{
var range = Microsoft.Office.Interop.Word.Document.GoTo(Name: name);
range.Text = text;
}
This works most of the time, but seemingly random, maybe one time in three, word crashes in module wwlib.dll. When that happens it may work using the same template with the same values.
This gives the following entry in the event log
Faulting application name: WINWORD.EXE, version: 16.0.11328.20468, time stamp: 0x5dbb4fb9
Faulting module name: wwlib.dll, version: 16.0.11328.20468, time stamp: 0x5dbb51fc
Exception code: 0xc0000005
Fault offset: 0x0156650e
Faulting process id: 0x8740
Faulting application start time: 0x01d5a9dfd64bc42a
Faulting application path: C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE
Faulting module path: C:\Program Files (x86)\Microsoft Office\Root\Office16\wwlib.dll
Report Id: 1db526da-b96e-48ad-bcaf-fa82da46240d
Faulting package full name:
Faulting package-relative application ID:
Continue reading...
The implementation loops over a dictionary with bookmarks as keys and texts as values. For each entry in the dictionary the following method is used to set the text.
public void SetFormFieldText(string name, string text)
{
var range = Microsoft.Office.Interop.Word.Document.GoTo(Name: name);
range.Text = text;
}
This works most of the time, but seemingly random, maybe one time in three, word crashes in module wwlib.dll. When that happens it may work using the same template with the same values.
This gives the following entry in the event log
Faulting application name: WINWORD.EXE, version: 16.0.11328.20468, time stamp: 0x5dbb4fb9
Faulting module name: wwlib.dll, version: 16.0.11328.20468, time stamp: 0x5dbb51fc
Exception code: 0xc0000005
Fault offset: 0x0156650e
Faulting process id: 0x8740
Faulting application start time: 0x01d5a9dfd64bc42a
Faulting application path: C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE
Faulting module path: C:\Program Files (x86)\Microsoft Office\Root\Office16\wwlib.dll
Report Id: 1db526da-b96e-48ad-bcaf-fa82da46240d
Faulting package full name:
Faulting package-relative application ID:
Continue reading...