Having Access Violation Exception when create .bmp image via TRIMdotNetSDK

Hello there,

TRIM version: 10.1.303.763

We have developed a small TrimTester application specifically to diagnose this AccessViolation Exception occurring in one particular environment hosted by our customer. Despite our efforts, we are still unable to determine the root cause of why this environment is causing our TrimTester to crash, while it functions without issues elsewhere where it has been hosted before.

Another strange thing is that this only happens for images with extensions .bmp and .png. 

The error we get:

Any new ideas would be appreciated thanks.

Kiet Tran

  • Hi Kiet,

    Can't say that I've ever had a need to use the CommitTrans method on a DB

    Are you able to share more of your tester code so that we may be able to attempt to reproduce?

    Any reason as to why you are going down the BeginTrans / CommitTrans route instead of just modifying the objects directly?


  • Hi Scotty,

    Thanks for the quick reply.

    We use the CommitTrans route so that we can roll back (we do this in our main code) when something is not right. It's just very odd that this is working for all other customers except for this new customer, particularly for .png and .jpeg types. I will do another test without using CommitTrans().

    code snippet of the TrimTester:

                If chkUseTransaction.Checked Then
                End If
                Dim rt As TRIMdotNetSDK.RecordType
                If (True) Then
                    rt = New TRIMdotNetSDK.RecordType(dotNetDatabase, txtRecordType.Text) ' //"Case File"); //container.RecordType);
                    rt = New TRIMdotNetSDK.RecordType(dotNetDatabase)
                End If
                Dim rec As TRIMdotNetSDK.Record = New TRIMdotNetSDK.Record(rt)
                If txtRecordNumber.Text > "" Then rec.LongNumber = txtRecordNumber.Text
                rec.Title = "Test Record - Title required by sdk"
                rec.Container = GetDotNetRecord(txtContainerNumber.Text)
                If txtRecordNumber.Text > "" Then txtRecordNumber.Text = rec.LongNumber
                Dim document_FileSystemPath = InputBox("Path to file to store", "", "C:\BTErrLog.txt")
                If True Then
                    ' //Set the ACTUAL electronic document
                    Dim trimInputDocument = New HP.HPTRIM.SDK.InputDocument()
                    'Logbook.LogDocV(logCtx + "file system file linked with record");
                    rec.SetDocument(trimInputDocument, False, False, "Comments")
                    'Logbook.LogDocV(logCtx + "document saved in TRIM");
                End If
                If chkUseTransaction.Checked Then
                End If
            Catch ex As Exception
            End Try

  • Suggested Answer


    - Have you attempted saving .BMP and .JPEG files via the SDK without using BeginTrans / CommitTrans?

    - Have you tried saving .BMP and .JPEG files using the native client?

    - Have you reviewed the workgroup server logs for any exceptions or errors?

    You could also try the below to tracking memory leaks

    Leak tracking

    The SDK provides a leak tracking mechanism, for reporting and tracking down SDK objects that are not properly disposed. Leak tracking can be enabled and disabled using the TrimApplication.EnableSdkLeakTracking() method. Leak tracking is enabled by default.

    When leak tracking is enabled, the first leak of an object will be reported to the Windows application event log, with a message containing the call stack location where the object was allocated. Subsequent leaks can be retrieved by calling TrimApplication.GetSdkLeakCount() and TrimApplication.GetSdkLeakStackTraces().

  • Thanks for the reply . Yes saving those without the transaction works correctly and the native client works correctly also. We will have a look at the leak methods.  This is only failing on a customer's installation

  • For completeness the System.AccessViolationException is not normally captured by a .net Try/Catch.

    For this error the following setting needs to be applied in an app.config - <legacyCorruptedStateExceptionsPolicy enabled="true" />

    without this setting the application crashes and an error is reported in event viewer