Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » ASSERT fail in LoadAccelTable(..) function call Collapse All
Subject Author Date
Saroj Acharya Jul 20, 2004 - 9:48 AM

I am having strange problem with my project. I have installed the V2.25 latest patch and use VC++ 7.10.


I get assert ERROR in the follwoing line of the code (file is winfrm.cpp). This happens only if I create certain COM Objects in my project. There is a function in my code to instantiate these COM objects. If I bypass these lines, I see no issues . Any idea where it is coming from ?


Thanks in advance.


 


Saroj


BOOL CFrameWnd::LoadAccelTable(LPCTSTR lpszResourceName)


{


ASSERT(m_hAccelTable == NULL); // only do once


ASSERT(lpszResourceName != NULL);


HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_ACCELERATOR);


m_hAccelTable = ::LoadAccelerators(hInst, lpszResourceName);


return (m_hAccelTable != NULL);


}


Function to instantiate the COM objects....


BOOL CMainFrame::InitializeVisionSystem()


{


HRESULT retVal;


try


{


// Initialize the COM library


// retVal = CoInitialize(NULL);


// if( !((retVal == S_FALSE) || (retVal == S_OK )) ) // If not previously initialized or Initialization fails,


// return(FALSE); // return FALSE


retVal = pApplication.CreateInstance(_T("MIL.Application"));


if(!ErrorDescription(retVal))


return(FALSE);


pSystem = pApplication->CreateObject(_T("MIL.System"), FALSE);


pDigitizer = pApplication->CreateObject(_T("MIL.Digitizer"), FALSE);


pDigitizer->OwnerSystem = pSystem;



if(blnOFFLineVersion)


pSystem->SystemType = _T("VGA");


else


pSystem->SystemType = _T("Meteor_II");


pSystem->Allocate();


Wait(1000);


// Only allocate the digitizer if it is supported


if ((pSystem->NumberOfDigitizers != 0) && (!pDigitizer->IsAllocated))


{


pDigitizer->Allocate();


}


pImageProcessing = pApplication->CreateObject(_T("MIL.ImageProcessing"), FALSE);


pImageProcessing->OwnerSystem = pSystem;


pImageProcessing->Allocate();


}


catch(COleDispatchException* pException)


{


CString CErrorMessage;


CErrorMessage = pException->m_strDescription;


CErrorMessage = CErrorMessage + _T("\n");


CErrorMessage = CErrorMessage + pException->m_strSource;



AfxMessageBox(CErrorMessage, MB_OK, 0);


pException->Delete();


return(FALSE);


}


catch(...)


{


CString CErrorMessage;


CErrorMessage.LoadString(IDS_UNHANDLED_EXCEPTION);


AfxMessageBox(CErrorMessage, MB_OK, 0);


return(FALSE);


}


return(TRUE);


}


 


 

Technical Support Jul 21, 2004 - 4:16 AM

Didn’t you forget to call something like CoInitialize, OleInitialize, or AfxOleInit? This is usually placed in the InitInstance virtual method of your CWinApp derived class.

Saroj Acharya Jul 21, 2004 - 9:45 AM

Hi,


I have tried calling CoInitialize(NULL) from the same function but it does not change anything. I will try OleInitialize() or AfxOleInit() from InitInstance() and see if solves the problem.


Another thing I noticed was that when LoadAccelTable(..) function is called, the value of m_hAccelTable is already something. It means the variable has already been initialized. Microsoft code also says...call it only once. Any idea why LoadAccelTable(..)  might be called twice ?


   ASSERT(m_hAccelTable == NULL); // only do once


Appreciate your help and support.


Saroj


 

Technical Support Jul 22, 2004 - 1:48 AM

The LoadAccelTable API should really be called only once. We suppose the error is somewhere in the CMainFrame::OnCreate method in which you may use an invalid initialization sequence for Prof-UIS-related features. Please pay attention to this method and look at how it is implemented in Prof-UIS samples.

Dmitry Dulepov Jul 23, 2004 - 1:54 AM

I remember I had the same problem when I used customization subsystem and passed incorrect parameters to customization subsystem... Do not remember details but worth to check.