Vista String bug … it’s done!
I am glad to inform you, that I finally managed to solve the Vista string bug of the Irrlicht.NET CP wrapper (See the posting in the forum)
The problem was based on the fact that .NET marshalling does an implicit freeing of memory allocated in the unmanaged wrapper part and being returned as a function return value. Rewriting the code in Irrlicht.NET lib so this freeing is not done implicitly by the managed code, but by calling a special, newly introduced method for memory freeing in the unmanaged wrapper (freeUMMemory(…)) helped resolving the crashes.
string value;
try
{
//New way for string marshalling according to
// http://www.mono-project/Interop_With_Native_Libraries
ptr_value = GUIListBox_GetListItem(_raw, id);
value = Marshal.PtrToStringAnsi(ptr_value);
}
And the new code for memory release in unmanaged memory areas:
{
//New method used to free memory allocated in C++ wrapper
freeUMMemory(ptr_value, true);
}
The security issue with requirement of admin rights to run the app remains.
The new code needs testing with unicode chars, to see if all works correct.
Furthermore testing on Windows XP and Linux is required, but as I sticked to code examples from the mono project I am quite optimistic for it to work at least under Linux.
Edit: As a further remark I just tested the code on WindowsXP and it worked. So let’s hope lester can get it to work under Linux.
Good night all.
Thoran
Filed under Uncategorized