Background:
I am creating a VC++ .NET wrapper for a C++ DLL; the aim is to use this wrapper in C# as shown below:
Range r = new Range( 2, 2 );
r[ 0 ][ 0 ] = new Cell( “Hello Mum” );
Range is a managed wrapper around an unmanaged range class. Vector is a managed wrapper around an unmanaged vector class. Cell is a managed wrapper around an unmanaged cell class.
Here r[ 0 ] returns a managed Vector* and r[ 0 ][ 0 ] accesses a particular Cell in the Vector.
Question:
In my wrapper class, the first indexer r[ 0 ] always returns an invalid unmanaged vector instance if I create the class instance with a pointer.
So, the following works fine using the copy constructor, if the vec has length 2 in VC++, it has a length 2 in C# …
vector* _vector;
Vector::Vector( vector& vec )
{
try
{
vector* wrappedVector = new vector( vec );
_vector = wrappedVector;
}
…
}
However, when I initialize the class by passing a pointer to an existing unmanaged vector class instance, the unmanaged vector object becomes invalid as soon as I reach the C# code (it is fine in the VC++), if the vec has length 2 in VC++, it has a length 0 in C#…
vector* _vector;
Vector::Vector( vector* vec )
{
try
{
_vector = vec;
}
…
}
Any ideas?
---
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.