You are viewing limited content. For full access, please sign in.

Question

Question

document can not create because document already exists

asked on December 2, 2016 Show version history

Hello

We been having problems with our SDK program with files not loading to into repository.    Some files in order of 1% when we are processing multiple files at once.

our program takes list of files as pdf converts them into Tiff on the hard drive.   The program then creates a empty document which we import the tiff into 

 

SeparateDocuments = True  'set earlier

We are using LFSO92.

Exception occurs on FileNo = 2 of the loop.


' Create all laserfiche document(s)
        For FileNo = 1 To TotalFiles
            ' Create empty laserfiche document
            If FileNo = 1 Or SeparateDocuments = True Then
                If FileNo > 1 And SeparateDocuments = True Then
                    Doc.Update()
                    If RushBatch Then
                        DocPages = Doc.Pages
                        Page = DocPages.Item(1)
                        Annotation = Page.AddAnnotation(Annotation_Type.ANN_TEXTBOX)
                        Annotation.Text = "RUSH BILL"
                        AnnotationRect = Annotation.Rectangle
                        AnnotationRect.Top = 10
                        AnnotationRect.Bottom = 250
                        AnnotationRect.Left = 100
                        AnnotationRect.Right = 1000
                        Annotation.FillColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Red))
                        Page.Update()
                    End If

                    Doc.Dispose()
                   
                End If
                Dim entryID As Integer = 0
                Try
                    Doc.Create(PrepOper & "_" & ScanOper & "_" & _
                        Mid(Folder, Len(Folder) - 1) & "_" & BolFlag & "_" & _
                        Mid(Folder, 1, Len(Folder) - 3), ParentFolder, Vol, True)
                    entryID = Doc.ID
                    If entryID = 0 Then
                        Throw New Exception("failed to create " & PrepOper & "_" & ScanOper & "_" & _
                        Mid(Folder, Len(Folder) - 1) & "_" & BolFlag & "_" & _
                        Mid(Folder, 1, Len(Folder) - 3))
                    End If
 

We get the following error

System.Runtime.InteropServices.COMException occurred
  ErrorCode=-2147220729
  Message="Create cannot be called on an object that already exists in the database."
  Source=""
  StackTrace:
       at LFSO92Lib.LFDocumentClass.Create(String Name, LFFolder ParentFolder, LFVolume Volume, Boolean AutoRename)    at LaserficheLoader.ClientClass.CreateDocument() in C:\LASERLOADER\Laserloader-add_delay\LaserLoaderServer-Delay\ClientClass.vb:line 1060
  InnerException: 

The other exception that we get is 
Line An Item with the same key has already been addeed.  is not valid and will be skipped

 

Is there way  ensure the previous document is released so we can create a new one?

0 0

Replies

replied on December 2, 2016

It's not enough to Dispose() the old document object (although you should do that).  You need to also create a new object before calling Create() on it.  My VB.Net is a little rusty, but I think you want something like

Doc = New LFDocument

just before you call Create().

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.