Free Support Forum - aspose.com

Error : item has already been added

Hi,
I encounter the following errors when using ASPOSE.WORD

Line 411: End If
Line 412: System.IO.File.Copy(docFile, destFile, True)
Line 413: Dim tempDoc As New Document(destFile)
Line 414: Dim tempBuilder As New DocumentBuilder(tempDoc)
Line 415: doc = tempDoc
Source File: C:\HOME\PROD-EAMS\forms\formsCCF.aspx.vb Line: 413

Stack Trace:


[ArgumentException: Item has already been added. Key in dictionary: “Body Text 2” Key being added: “Body Text 2”] System.Collections.SortedList.Add(Object key, Object value) +221 Aspose.Word.Styles.?(Style ?) +108 ?.?.?(Int32 ?) +138 ?.?.?(BinaryReader ?, Int32 ?, Int32 ?) +133 ?.?.?() +720 Aspose.Word.Document.?(Stream ?, String ?) +259 Aspose.Word.Document…ctor(String fileName) +76 PROD_EAMS.formsCCF.btnSub_Click(Object sender, EventArgs e) in C:\HOME\PROD-EAMS\forms\formsCCF.aspx.vb:413 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292 

My codes :

If assetInfo.HasRows Then

docFile = docPath & “\template1.doc”

assetType = oracleAssetType

destFile = docPath & “\temp.doc”

Else

docFile = docPath & “\template2.doc”

assetType = nonOracleAssetType

destFile = docPath & “\temp.doc”

End If

System.IO.File.Copy(docFile, destFile, True)

Dim tempDoc As New Document(destFile)

Dim tempBuilder As New DocumentBuilder(tempDoc)


Appreciate your help

thanks
Desmond

Hi Desmond,

Thank you for considering Aspose.

Please make sure you are using the latest version of Aspose.Word because this issue should be recently fixed. If the problem persists, attach your document.