How can I find where in unmanaged code (3rd party DLL) an exception occurs?

-4

I am using a 3rd party DLL, written in c++ of some flavor. I am calling it from VB.NET code I wrote. The API contains a myriad of functions. To get everything started I call 6 different functions with no issue. When I call the last & most complex function I get;

First-chance exception at 0x00007ff8613be1d6 in EditsShell50.exe: 0xC0000005: Access violation reading location 0x00000000380ef150.

The debugger stops at the line calling the complex function. By complex function I mean two things,

  1. It does a lot of different stuff.
  2. I does call back functions to my code.

The first 6 functions do not do call backs to my code. Interestingly this dll comes in an x86 version and an x64 version. My code works with the x86 version flawlessly.

So my question is how can I find what in the 3rd party dll is executing that generates the error?

Edit:

In case anyone cares why I want to compile and run in "Any CPU" or x64 mode, I have installed a new server with Oracle on it, and I do not want to install the x86 Oracle client on this computer because the x86 12cR2 ODP.NET was/is buggy.

Edit:

So you want to see code, here are the bits I believe are relevant;

Declare Function Edit_RunEdits Lib "EDITS50.DLL" (ByVal smfID As Integer, _
                                                  ByVal edit_tag As String, _
                                                  ByVal layout_tag As String, _
                                                  ByVal data As String, _
                                                  ByVal edit_options As Integer, _
                                                  ByRef errors_count As Integer, _
                                                  ByVal owner As IntPtr, _
                                                  ByVal callback_func As IntPtr) As Integer


Private _objThis As GCHandle = GCHandle.Alloc(Me)
Private _ptrThis As System.IntPtr = GCHandle.ToIntPtr(_objThis)

Private _objEditsMessagerHandler As New EditsMessagerHandlerDelegate(AddressOf EditsMessagerHandler)
Private _objGCHEditsMessageHandler As GCHandle = GCHandle.Alloc(_objEditsMessagerHandler)
Private _ptrEditsMessagerHandler As System.IntPtr = Marshal.GetFunctionPointerForDelegate(_objEditsMessagerHandler)

Private _objEditsFieldsHandler As New editsErrorFieldsHandlerDelegate(AddressOf editsErrorFieldsHandler)
Private _objGCHEditsFieldsHandler As GCHandle = GCHandle.Alloc(_objEditsFieldsHandler)
Private _ptrEditsFieldsHandler As System.IntPtr = Marshal.GetFunctionPointerForDelegate(_objEditsFieldsHandler)


Edit_RunEdits(_intsmfID, _strEditSetTag, _strEditLayoutTag, strNAACCRRecord, EE_SKIPFAIL, intErrCount, _ptrThis, _ptrEditsMessagerHandler)

Failing line of code^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

' EditsMessagerHandlerDelegate is the prototype of the module to handle call backs from Edit_RunEdits.
' This is required for inter operation with unmanaged services.
<UnmanagedFunctionPointer(CallingConvention.Cdecl)>
Public Delegate Sub EditsMessagerHandlerDelegate(ByRef objThis As System.IntPtr, _
    <InAttribute()> <MarshalAsAttribute(UnmanagedType.LPStr)> ByVal strEditTag As String, _
    <InAttribute()> <MarshalAsAttribute(UnmanagedType.LPStr)> ByVal strEditName As String, _
    <InAttribute()> <MarshalAsAttribute(UnmanagedType.LPStr)> ByVal strAdminCode As String, _
    <InAttribute()> <MarshalAsAttribute(UnmanagedType.LPStr)> ByVal strErrorType As String, _
    <InAttribute()> <MarshalAsAttribute(UnmanagedType.LPStr)> ByVal strMessage As String)

' EditsMessagerHandler is the actual module that handles errors from Edit_RunEdits.
' Please see the EDITS50 API documentation for information regarding parameters.
' The main functionality is to build the list of error messages to be processed by the calling module.
Private Sub EditsMessagerHandler(ByRef objThisIn As System.IntPtr, _
                                  ByVal strEditTag As String, _
                                  ByVal strEditName As String, _
                                  ByVal strAdminCode As String, _
                                  ByVal strErrorType As String, _
                                  ByVal strMessage As String)

EDIT:

Too broad? How is this too broad? I have a specific error that happens under a specific set of circumstances which I clearly define. What more would you like?

c++
.net
vb.net
asked on Stack Overflow Oct 4, 2018 by Paul Stearns • edited Oct 5, 2018 by Paul Stearns

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0