Dear Sir/Madam,
When I use C# Interop.Word to open a document, and then close the document. Then I am trying to reopen the same document or open another document, somehow I always hit an error message "System.Exception: Cannot open more than one word document!". The full exception stack trace is shown below:
============================================================
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Exception: Cannot open more than one word document!
at DanielTest.Form1.RunBizDoc_Plain(BizDocConfigurationStruct BizDocConfigurationParameters, BizDocOutputStruct& BizDocOutputs, String& runStatus) in D:\TrustedHub\doc\BizDoc\Projects\DanielTest\Form1.cs:line 3434
at DanielTest.Form1.btnPlainProgramming_Click(Object sender, EventArgs e) in D:\TrustedHub\doc\BizDoc\Projects\DanielTest\Form1.cs:line 4948
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3640.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
DanielTest
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/BizDoc/Application/BizDocTest/Program/DanielTest.exe
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3580.0 built by: NET472REL1LAST_C
System
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3640.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3630.0 built by: NET472REL1LAST_B
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3640.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3630.0 built by: NET472REL1LAST_B
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3260.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
System.Web.Services
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Web.Services/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
GdPicture.NET.14
Assembly Version: 14.1.0.119
Win32 Version: 14.1.0.119
CodeBase: file:///E:/BizDoc/Application/BizDocTest/Program/GdPicture.NET.14.DLL
Microsoft.Office.Interop.Word
Assembly Version: 15.0.0.0
Win32 Version: 15.0.4603.1000
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Interop.Word/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Word.dll
office
Assembly Version: 15.0.0.0
Win32 Version: 15.0.4613.1000
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll
System.Runtime.Caching
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Caching/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.Caching.dll
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
itextsharp
Assembly Version: 5.5.13.2
Win32 Version: 5.5.13.2
CodeBase: file:///E:/BizDoc/Application/BizDocTest/Program/itextsharp.DLL
CustomMarshalers
Assembly Version: 4.0.0.0
Win32 Version: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/CustomMarshalers/v4.0_4.0.0.0__b03f5f7f11d50a3a/CustomMarshalers.dll
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
My C# source codes to open a document is listed below:
============================================================
gWordDoc.pubWordDoc = gWordDoc.pubWordApp.Documents.Open(oFilePath, oMissing, oFalse, oFalse, oPassword, oMissing, oTrue, oPassword, oMissing, oMissing, oMissing, oFalse);
My C# source codes to close a document is listed below:
============================================================
gWordDoc.pubWordDoc.Close(0);
Can anybody help me to solve the issue?
Thanks.
Rgds,
Daniel