Highlighted
Visitor.
169 views

AccessViolationException when creating a new record with HP CM 9.1

Hello guys,

 

My application is terminated by AccessViolationException when it tries to create a new record to HP CM 9.1 server.

 

My application is 64bit .NET windows service, a new record is created using .NET SDK (HP.HPTRIM.SDK.dll, version 8.2) with following C# code:

 

        private string PutFile(string sourceFilePath, string title, string recordType,
            string conatinerRecordNumber, string externalId, string author)
        {
            using (var database = CreateDatabase())
            {
                var newDocument = new InputDocument();
                newDocument.SetAsFile(Path.GetFullPath(sourceFilePath));

                var newRecord = new Record(new RecordType(database, recordType));
                // !!! this line is not reached, the error happens in the previous one
                newRecord.SetDocument(newDocument, false, false, "Created by SafeQ6");

                newRecord.Title = title;
                if (!string.IsNullOrWhiteSpace(conatinerRecordNumber))
                {
                    newRecord.Container = new Record(database, conatinerRecordNumber);
                }
                newRecord.ExternalReference = externalId;
                if (!string.IsNullOrWhiteSpace(author))
                {
                    newRecord.Author = new Location(database, author);
                }

                newRecord.Save();
            }
            return title;
        }

        private Database CreateDatabase()
        {
            Database database = new Database
            {
                Id = databaseId,
                WorkgroupServerURL = workgroupServerUrl,
                AlternateWorkgroupServerURL = workgroupServerUrl
            };
            database.AuthenticationMethod = ClientAuthenticationMechanism.ExplicitWindows;
            database.SetAuthenticationCredentials(samUserName, credentials.Password);
            database.TrustedUser = userToImpersonate;
            database.Connect();
            return database;
        }

 

 

my application is terminated and in Windows Event Log there is :

 

 

Exception Info: System.AccessViolationException
   at HP.HPTRIM.SDK.trimPINVOKE.new_Record__SWIG_3(System.Runtime.InteropServices.HandleRef)
   at HP.HPTRIM.SDK.Record..ctor(HP.HPTRIM.SDK.RecordType)
   …

 

 

SDK initialisation was successful. 

 

My application is used daily by many users (one of them actually also has HP CM 9.1) without any issue so it seems that it might be specific to this one environment.

 

Do you have any idea what might be happening?

Do you have any hints what I could try to make it working?

Are you aware of any logs or additional data which might help me to find the cause?

 

Cheers 

0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: AccessViolationException when creating a new record with HP CM 9.1

I am not sure that it would be related to the error but your authentication strategy confuses me.  I would normally expect a service to run as in IntegratedWindows mode so it uses the service account.  The way you have it you need to store a user name password and the get the trusted user from somewhere.

Still I have a very limited window on the application so no doubt it is all OK.

 

As to the actual error you might try calling IsValid() on the database to confirm the Database is wired up correctly.


Blog | Samples | CM SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Highlighted
Visitor.

Re: AccessViolationException when creating a new record with HP CM 9.1

Hello @David Churchland ,

thank you for your quick reaction. To comment on our authentication, we actually tried both (IntegratedWindows and ExplicitWindows) with the same result. 

From the stack trace in the event log it looks like the database.Connect() was successful as the fault happened in Record constructor. However, I will add that database validity check you recommended to see if it changes anything.

 

I am not sure if it is relevant, but recordType argument is set to "Electronic Object".

0 Likes
Highlighted
Visitor.

Re: AccessViolationException when creating a new record with HP CM 9.1

Hi @David Churchland ,

`database.IsValid` returns `true` in the problematic environment with HP CM 9.1, but it still crashes during record creation.

 

0 Likes
Highlighted
Visitor.

Re: AccessViolationException when creating a new record with HP CM 9.1

Update: I have been able to verify the code above on a clean HP CM 9.1 installation and it works fine. So it looks like the issue might be environment specific.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.