Results 1 to 6 of 6

Thread: Access violation while loading.

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    2

    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


    ColladaObject.h
    Code :
    #pragma once
    #include <string>
    #include <fstream>
    #include <stdio.h>
    #include <DAE.h>
    #include <domSource.h>
    #include <domConstants.h>
     
    class ColladaObject
    {
    private:
    	DAE *daeObject;
    public:
    	ColladaObject(void);
    	~ColladaObject(void);
     
     
    	bool LoadObject(std::string filename);
    };

    ColladaObject.cpp
    Code :
    #include "StdAfx.h"
    #include "ColladaObject.h"
     
    ColladaObject::ColladaObject(void)
    {
     
    }
     
    ColladaObject::~ColladaObject(void)
    {
     
    }
     
     
    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)
    	{
    		...
    		...
    		...
    	}
    	else
    	{
    		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.
    [/quote]

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    You're forgetting to null the daeObject pointer, so it doesn't get new'd. Try this:
    Code :
    ColladaObject::ColladaObject(void)
    {
      daeObject = 0;
    }
    Better yet, don't use a pointer at all:
    Code :
    class ColladaObject
    {
    private:
       DAE daeObject;

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Posts
    2
    I tried not to use a pointer before and it didn't work, nulling the pointer also gives the same error

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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:
    Code :
    #include <iostream>
    #include <dae.h>
     
    using namespace std;
     
    int main() {
    	DAE dae;
    	if (dae.load("/c:/collada/cube.dae") != DAE_OK) {
    		cout << "failed\n";
    		cin.get();
    	}
    	return 0;
    }
    Replace the hard-code cube.dae reference with something appropriate for your setup of course. Does that work?

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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@y.com

    x = sthomas314
    y = gmail

  6. #6
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •