Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debug assertion failure

Status
Not open for further replies.

shetlandbob

Programmer
Mar 9, 2004
528
GB
Hello,

Ok this is a complete shot in the dark to see if anyone can assist?

First I am running someone else's code, he left the work last week!!

I've got a project which comiles and executes (debug and release) on the development machine, however when I copy it to another machine, which will be the main machine to execute it, the project fails.

I have copied across all librarys and "ocx" files (i also had to install many other development programs and they all work fine).

I even went as far as installing a version of Visual Studio.Net on the main machine. The project still fails to execute in debug or release.

I get as assertion error in file "occmgr.cpp". the line it fails on is:
Code:
	ASSERT(pTemp->m_hWnd);
The line it fails on in my host code is during the initInstance routine, shown below - the line in red is the one it fails on.
Code:
BOOL CDAQMANApp::InitInstance()
{
  [green]// Initialize OLE libraries[/green]
  if (!AfxOleInit())
  {
    AfxMessageBox(IDP_OLE_INIT_FAILED);
    return FALSE;
  }

  AfxEnableControlContainer();

[green]// Standard initialization
// If you are not using these features and wish to reduce the size
//  of your final executable, you should remove from the following
//  the specific initialization routines you do not need.
[/green]
#ifdef _AFXDLL
  Enable3dControls();			// Call this when using MFC in a shared DLL
#else
  Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

[green]//********* MUST BE IN ALL COM CLIENTS *********[/green]
  CoInitialize(NULL);

[green]// Parse the command line to see if launched as OLE server[/green]
  if (RunEmbedded() || RunAutomated())
  {
[green]// Register all OLE server (factories) as running.  This enables the
//  OLE libraries to create objects from other applications.[/green]
    COleTemplateServer::RegisterAll();
  }
  else
  {
[green]// When a server application is launched stand-alone, it is a good idea
//  to update the system registry in case it has been damaged.[/green]
    COleObjectFactory::UpdateRegistryAll();
  }
	
[green]//SetPriorityClass(this, REALTIME_PRIORITY_CLASS);[/green]

  CDAQMANDlg dlg(NULL);
  m_pMainWnd = &dlg;
  [red]int nResponse = dlg.DoModal();[/red]
  if (nResponse == IDOK)
  {
[green]// TODO: Place code here to handle when the dialog is
//  dismissed with OK[/green]
  }
  else if (nResponse == IDCANCEL)
  {
[green]// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel[/green]
  }
[green]// Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.[/green]
  return FALSE;
}

I also get the following in the debug window:

Code:
'DAQMAN.exe': Unloaded 'C:\WINNT\SYSTEM32\MSIMG32.DLL'
CoCreateInstance of OLE control {DC4020D7-462B-4296-97DB-F5E306BA4CA5} failed.
>>> Result code: 0x80040154
>>> Is the control is properly registered?
Unhandled exception at 0x7c1a9b1e (mfc71d.dll) in DAQMAN.exe: User breakpoint.
The program '[2228] DAQMAN.exe: Native' has exited with code 0 (0x0).


I have registered (all that it will allow) all dll's.


Does anyone have an ideas/suggestions/good luck messages that might give me some inspiration???

Much appreciated if you do!!!
 
Assertion errors trap all those "can never happen" cases inside the code - if the code has been written correctly.

Example
Code:
double square_root ( double x ) {
    ASSERT(x>=0.0);
    // safe to go on and calculate...
}
You can't calculate the square root of a negative (not without resorting to complex numbers), so there is no point in trying. This function uses ASSERT() to make sure users of the function are playing by the rules.

My guess would be from this code
Code:
  CDAQMANDlg dlg(NULL);
  m_pMainWnd = &dlg;
  int nResponse = dlg.DoModal();
would be that the creation of the object failed, so perhaps checking for failure would be a good thing to do.

--
 
Salem,

thanks for the info on asserts.

For info:

After much head scratching and head banging on walls I discovered the problems this arvo.

It was an activeX control that was built into the code was not registered in the release machine. (regsvr32 activeX.ocx)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top