J
JRoe
Hello,
I am beside myself with this problem.
I need to access unmanged C++ code in a C# environment. I have created
a managed C++ wrapper that wraps the unmanaged class.
When I call the constructor, it is returning undefined. Here is an
example:
Unmanaged C++
class Map_Interface
{
Map_Inteface()
{
...does stuff
}
}
Managed C++
#using mscorlib.dll
__gc class Map_Interface_Wrapper
{
private:
Map_Interface __nogc *myMapInterface;
public:
Map_Interface_Wrapper()
{ myMapInterface = new Map_Interface; }
};
C# Driver
.....
using Map_Interface_Wrapper;
Map_Interface_Wrapper aWrapper = new Map_Interface_Wrapper;
My problem is when the C# instantiates the Map_Interface_Wrapper, the
managed code constructor is being called and then calls the unmanaged
C++ constructor. When I step into this I see the objects being
initialized, but when it leaves the unmanaged constructor and returns
to the managed wrapper, the newly created object is still undefined. I
can see the address it is pointing to is the same as the unmanaged
object.
I have no idea how to fix this. I've been looking all over the
internet to see if anyone has had this problem and can't seem to find
it. All the documentation I've read shows to do it this way, but for
some reason it doesn't work for me. Perhaps I have a compilier setting
wrong in the IDE??
I would surely appreciate help on this.
Thanks in advance!
I am beside myself with this problem.
I need to access unmanged C++ code in a C# environment. I have created
a managed C++ wrapper that wraps the unmanaged class.
When I call the constructor, it is returning undefined. Here is an
example:
Unmanaged C++
class Map_Interface
{
Map_Inteface()
{
...does stuff
}
}
Managed C++
#using mscorlib.dll
__gc class Map_Interface_Wrapper
{
private:
Map_Interface __nogc *myMapInterface;
public:
Map_Interface_Wrapper()
{ myMapInterface = new Map_Interface; }
};
C# Driver
.....
using Map_Interface_Wrapper;
Map_Interface_Wrapper aWrapper = new Map_Interface_Wrapper;
My problem is when the C# instantiates the Map_Interface_Wrapper, the
managed code constructor is being called and then calls the unmanaged
C++ constructor. When I step into this I see the objects being
initialized, but when it leaves the unmanaged constructor and returns
to the managed wrapper, the newly created object is still undefined. I
can see the address it is pointing to is the same as the unmanaged
object.
I have no idea how to fix this. I've been looking all over the
internet to see if anyone has had this problem and can't seem to find
it. All the documentation I've read shows to do it this way, but for
some reason it doesn't work for me. Perhaps I have a compilier setting
wrong in the IDE??
I would surely appreciate help on this.
Thanks in advance!