I need some help diagnosing an SEHException: External component has thrown an exception

Greydog1 1 Reputation point
2020-10-18T20:59:21.26+00:00

This is a Windows Forms application using VB.Net and VS2012. It connects to an Access database with an oledbconnection and the 2013 Access Runtime. (It also connects with the corresponding SQLconnection to SQL Server without the problem below). The app is compiled to target x86. The problem is intermittent and occurs on multiple different PC's randomly, and accessing a database on a local hard drive.

Using cn As New OleDbConnection  
  System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor  
  If Not OpenDBConnection(cn) Then  
      System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default  
      MsgBox("Unable to make database connection to update screen status.", MsgBoxStyle.OkOnly, "Database Connection Error (MMUN1)")  
      Exit Sub  
  End If  
'continue processing....  
 end using  
  
Public Function OpenAccessConnection(ByRef conn As OleDb.OleDbConnection) As Boolean  
    Dim builder As New OleDbConnectionStringBuilder()  
  
    'conn.Provider = "Microsoft.ACE.OLEDB.12.0"         
    Try  
        builder.ConnectionString = "Data Source=" & DPATH & DBNAME  
        builder.Add("Provider", "Microsoft.ACE.OLEDB." & ACCESSVER & ".0")  'ACCESSVER is '12'  
        conn.ConnectionString = builder.ConnectionString  
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor  
        conn.Open()  
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default  
        Return True  
    Catch ex As Exception  
        MsgBox("Unable to make Access connection.  Error# " & Err.Number & " " & ErrorToString() & " " & ex.ToString, MsgBoxStyle.OkOnly, "Database Connection Error (OLEOPN1)")  
        Return False  
    Finally  
        builder.Clear()  
        builder = Nothing  
    End Try  
End Function  
  
Public Function OpenDBConnection(ByRef conn As OleDbConnection) As Boolean  
'I know this is an extraneous function call but it is in transition from multiple prior uses and I thought I had better not exclude it from this post in case it mattered for some reason  
    OpenDBConnection = OpenAccessConnection(conn)  
End Function  

The error which is being seen intermittently is:
33069-oleopn1.png

I have read many of the posts on this topic and have not found a solution, and frankly am not sure where to look. Could this be coming from an earlier application error? Thread/STA issue? If so, what can I do about it? On the development machine, I will on occasion see a DisconnectedContext error, but have not seen the External component error which appears on PC's running the released version. Could these be related? Also, in case it matters, there are some ADO (ADODB) connections being made to the database (still trying to replace/upgrade), but these are not open at the time this new connection is being made. But could it be a connection pooling issue? I'm wondering if it is possible there is a connection pool race condition or something. I know it's hard for you folks out there to diagnose an intermittent issue, but I'm just looking for a clue as to what it COULD be, and how I can go about either diagnosing or resolving it. Thanks so much!

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,798 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,596 Reputation points
    2020-10-19T08:27:07.807+00:00

    Hi Greydog1,
    When you use OleDbConnection to connect Access database, you need to note that the OleDbConnection object does not support setting or retrieving dynamic properties specific to an OLE DB provider. Only properties that can be passed in the connection string for the OLE DB provider are supported.
    More details you can refer to this document.
    And about how to diagnose the error SEHException, you can try to use ExternalException.ErrorCode property.
    Please refer to this thread.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Greydog1 1 Reputation point
    2020-11-02T06:45:24.84+00:00

    For anyone else looking at this issue, I refer you to this post: 8ff4d227-7cf3-4caf-8706-9ce0b4777a9a

    While the conditions listed are slightly different, I believe the underlying cause is the same. We experienced both intermittent, non-erroring crashes as well as the intermittent SEH exception. When we reinstalled the Access Runtime, the issues appear to have been resolved, at least until the next MS update.

    0 comments No comments