Access violation while loading.

Hi i’m using the newest version of DOM and Visual Studio Express 2008 and i get a memory error while loading a .dae document. Can anoyone help me, i can’t find the problem :?


#pragma once
#include <string>
#include <fstream>
#include <stdio.h>
#include <DAE.h>
#include <domSource.h>
#include <domConstants.h>

class ColladaObject
	DAE *daeObject;

	bool LoadObject(std::string filename);


#include "StdAfx.h"
#include "ColladaObject.h"





bool ColladaObject::LoadObject(std::string filename)
	daeInt ret;
	if(daeObject == NULL)
		daeObject = new DAE;

	ret = daeObject->load(filename.c_str());  // Here the program stops
	if(	ret == DAE_OK)
		return false;
	return true;

And here’s the error thrown out by visual.

‘Obj2Bob2.0.exe’: Loaded ‘C:\WINMX\system32\wldap32.dll’
First-chance exception at 0x102d295a in Obj2Bob2.0.exe: 0xC0000005: Access violation reading location 0x6e656347.
A first chance exception of type ‘System.AccessViolationException’ occurred in Obj2Bob2.0.exe
An unhandled exception of type ‘System.AccessViolationException’ occurred in Obj2Bob2.0.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


You’re forgetting to null the daeObject pointer, so it doesn’t get new’d. Try this:

  daeObject = 0;

Better yet, don’t use a pointer at all:

class ColladaObject
   DAE daeObject; 

I tried not to use a pointer before and it didn’t work, nulling the pointer also gives the same error :slight_smile:

What exactly is your build setup? Did you convert the DOM project files to VS 2008 and build like that, or did you build the DOM with 2005 and try to use those .libs in your 2008 app? Are you using the DOM static libs or the DLL?

Try making a plain vanilla VS 2008 C++ empty project using this test file:

#include <iostream>
#include <dae.h>

using namespace std;

int main() {
	DAE dae;
	if (dae.load("/c:/collada/cube.dae") != DAE_OK) {
		cout << "failed
	return 0;

Replace the hard-code cube.dae reference with something appropriate for your setup of course. Does that work?

I just tried making a test app in VS 2008 Express using the static DOM libs built with VS 2005. I used the code I posted above. I had to add ‘msvcrt.lib’ to the “Ignore Specific Library” field in the linker property settings, otherwise it would fail on startup saying that it couldn’t find msvcr90.dll. Once I did that though, it worked fine.

I think there may still be something wrong with your code. If you email me your build files (including .sln/.vcproj files), I’ll try out your app.

x = sthomas314
y = gmail

The Birdman and I were able to work this out over email. He was using a C++/CLI app and I think that was complicating things. When he switched to using the DOM DLL (instead of the static lib) everything worked fine. I’m not sure why the static lib didn’t work, but maybe this info will help other .Net developers that want to use the DOM in the future.