System.Runtime.InteropServices.SEHException - Crystal Report Runtime SP27

0

This is the piece of code that is throwing that exception:

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes

#include <afxwinforms.h>
void function(){   
CDocument* pDocument = CreateNewDocument();
    if (pDocument == NULL)
    {
       AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
       return NULL;
    }
    ASSERT_VALID(pDocument);
    _SetDocumentDetails(lpszPathName, pDocument);
    BOOL bAutoDelete = pDocument->m_bAutoDelete;
    pDocument->m_bAutoDelete = FALSE;
    CFrameWnd* pFrame = NULL;

    pFrame = CreateNewFrame(pDocument, NULL);  // throws error dialog box
}

I'm upgrading my Crystal report runtime for visual studio from SP16 to the latest one, SP 27, but after building my whole application and running it, when I open a crystal report, it goes through that piece of code and I end up having an error dialog showing:

Debug Assertion Failed! 
Program: C:\WINDOWS\SYSTEM32\mfc140d.dll 
File: d:\agent_work\8\s\src\vctools\VC7Libs\Ship\ATLMFC\Src\MFC\occsite.cpp
Line:1007

and if I click on Ignore it shows me the stack trace which is this one:

************** Exception Text **************
System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at COleControlSite.AttachWindow(COleControlSite* )
   at Microsoft.VisualC.MFC.CWinFormsControlSite.OnHandleCreatedHandler(CWinFormsControlSite* )
   at Microsoft.VisualC.MFC.CWinFormsControlSite.OnHandleCreated(CWinFormsControlSite* , Object A_0, EventArgs A_1)
   at Microsoft.VisualC.MFC.CWinFormsEventsHelper.OnHandleCreated(Object o, EventArgs args)
   at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at CrystalDecisions.Windows.Forms.CrystalReportViewer.WndProc(Message& msg)
   at System.Windows.Forms.Control.ActiveXImpl.System.Windows.Forms.IWindowTarget.OnMessage(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

And then my report is being launched as normal, as if nothing happened.

I'm running VS17, VC Redistributable x64 and x86 14.25.28508, .NET Framework 4.8 and SP any from 25 to 27.

If I install any other SP from 16 to 24 they all work fine. Also on the wiki is says that VS17 is supported from SP21 and higher so I was expecting SP27 to be working fine with VS17 as well.. but it doesnt seem the case, since from SP25 it keeps throwing that exception for me

Looking at the occsite.cpp file this is the function throwing the error

void COleControlSite::AttachWindow()
{
    ENSURE_ARG(m_pInPlaceObject!=NULL);
    HWND hWnd = NULL;
    if (SUCCEEDED(m_pInPlaceObject->GetWindow(&hWnd)))
    {
        ASSERT(hWnd != NULL);
        if (m_hWnd != hWnd)
        {
            m_hWnd = hWnd;

            if (m_pWndCtrl != NULL)
            {
                ASSERT(m_pWndCtrl->m_hWnd == NULL); // Window already attached?
                m_pWndCtrl->Attach(m_hWnd);

                ASSERT(m_pWndCtrl->m_pCtrlSite == NULL ||
                    m_pWndCtrl->m_pCtrlSite == this);
                m_pWndCtrl->m_pCtrlSite = this;
            }
        }
    }
}
c++
visual-studio
crystal-reports
asked on Stack Overflow May 14, 2020 by Riad

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0