Generic list from C++ to C#

N

Nicolas Fleury

Hi,

I have a field named "BaseClasses" in C++ as in the following simplified
code:

using Collections::Generic::List;
namespace A2M { namespace LipIntrospection {
public ref class BaseClassInfo
{
...
};

public ref class ClassInfo
{
public:
List<BaseClassInfo^> BaseClasses;
...
};
}}

The problem is that when "BaseClasses" is accessed in C#, I get an error
"is not supported in the language". I'm able to use the BaseClassInfo
class without problem and I'm also able to define a List<BaseClassInfo>
in C#. Out of curiosity, I compared the types of the list in C# and C++
and I got the following:

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29053, Culture=neutral,
PublicKeyToken=null]]"

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29233, Culture=neutral,
PublicKeyToken=null]]"

Is it possible that C++ and C# are using different versions of the
generic list?

Note that I'm pretty new to .Net and C#, so maybe I'm missing something?

Thx and regards,
Nicolas Fleury
 
W

Willy Denoyette [MVP]

Nicolas Fleury said:
Hi,

I have a field named "BaseClasses" in C++ as in the following simplified
code:

using Collections::Generic::List;
namespace A2M { namespace LipIntrospection {
public ref class BaseClassInfo
{
...
};

public ref class ClassInfo
{
public:
List<BaseClassInfo^> BaseClasses;
...
};
}}

The problem is that when "BaseClasses" is accessed in C#, I get an error
"is not supported in the language". I'm able to use the BaseClassInfo
class without problem and I'm also able to define a List<BaseClassInfo> in
C#. Out of curiosity, I compared the types of the list in C# and C++ and
I got the following:

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29053, Culture=neutral,
PublicKeyToken=null]]"

"System.Collections.Generic.List`1[[A2M.LipIntrospection.BaseClassInfo,
LipIntrospection, Version=1.0.2196.29233, Culture=neutral,
PublicKeyToken=null]]"

Is it possible that C++ and C# are using different versions of the generic
list?

Note that I'm pretty new to .Net and C#, so maybe I'm missing something?

Thx and regards,
Nicolas Fleury

List<BaseClassInfo^> BaseClasses;

should be

List<BaseClassInfo^> ^BaseClasses;

C# does not support stackbased semantics, so you must declare a reference.

Willy.
 
N

Nicolas Fleury

Willy said:
List<BaseClassInfo^> BaseClasses;

should be

List<BaseClassInfo^> ^BaseClasses;

C# does not support stackbased semantics, so you must declare a reference.

Oups. Thx, stupid mistake from me; haven't notice it for this field
because the preceding field was a simple type.

Thx,
Nicolas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top