Trying to write a Wrapper, but i need Help :)

Bostich

24-08-2008 16:37:20

Hello Mogre Com :),

First, iam very new to the Mogre/Ogre World (I know it since ~ 1 week :wink: ).

While browsing the Forums here, i have found the very nice Hydrax plugin. The only "bad" thing about Hydrax is, that it isnt written in C# (My favourite language). So i decided (to try :D ) to write a wrapper for this nice plugin.

So now here beginns my problem.

Here is a code Snippet from the Wrapper Constructor:




public: MHydrax(Mogre::SceneManager^ mSceneMgr, Mogre::Camera^ mCamera){
Ogre::SceneManager* sm = (Ogre::SceneManager*)mSceneMgr;
Ogre::Camera* cam = (Ogre::Camera*)mCamera;
mHydrax = new Hydrax::Hydrax(sm,cam);
}


Ok now my C# object creation:

//Create Hydrax object
mHydrax = new MHydrax.MHydrax(mSceneMgr,mCamera);


While Starting the C# Program, it opens the MHydrax.h file, points to the Ogre::Camera object, and says:


[System.AccessViolationException]
{"'Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}


So hopefully anyone of you can say me, what iam doing wrong here. And please keep in mind, i never wrote a wrapper before :P

ps: Sorry for my english (German native speaker :P )

Bostich

//Edit:

Mh ok, i poinetd out that this isnt a problem of the Camera cast. The problem seem to occour while calling the Hydrax constructor :/. But i have no idea why^^

//Edit2:
Very interesting :
if i start the C# project in release mode, everything works fine. very strange....

//Edit3:
Ok, iam Nearly finished with the wrapping lib and i think i have figured out why the AccessViolation occurs.

This exception throws only whenever Hydrax is callin HydraxLog();
Message is ("Access violation reading location 0xcccccccc").
Mabye, someone can helpme with that :).

But now i have to go to bed :P 8)