473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Pass Generic::List in C++ Library to vb.net

Nip
Hi
I want to access the Generic List of the following c++-class inside a vb.net
app. Is this possible/how can I do that?
Atm, I get the following error in the vb.net app: "Field 'GeoElems' is of
an unsupported type."

public ref class clsPhysik
{
......
public: System::Collections::Generic::List<GeoElem^GeoElem s;
......
}

Jan 5 '07 #1
8 1999
My book says System::Collections::Generic classes are not CLS
compliant. So they are unsupported, with the usual caveats.

RL
Nip wrote:
Hi
I want to access the Generic List of the following c++-class inside a vb.net
app. Is this possible/how can I do that?
Atm, I get the following error in the vb.net app: "Field 'GeoElems' is of
an unsupported type."

public ref class clsPhysik
{
.....
public: System::Collections::Generic::List<GeoElem^GeoElem s;
.....
}
Jan 5 '07 #2
raylopez99 wrote:
My book says System::Collections::Generic classes are not CLS
compliant. So they are unsupported, with the usual caveats.
I seriously doubt that. Here's an example how to use Generic.List in VB.NET:

http://msdn2.microsoft.com/en-us/library/6sh2ey19.aspx

Tom
Jan 5 '07 #3

"Nip" <lu***@quantentunnel.dewrote in message
news:eW*************@TK2MSFTNGP06.phx.gbl...
Hi
I want to access the Generic List of the following c++-class inside a
vb.net app. Is this possible/how can I do that?
Atm, I get the following error in the vb.net app: "Field 'GeoElems' is of
an unsupported type."

public ref class clsPhysik
{
.....
public: System::Collections::Generic::List<GeoElem^GeoElem s;
You're using C++/CLI stack semantics, which aren't supported by any other
language. You must exposed the tracking handle. Try:

private: System::Collections::Generic::List<GeoElem^m_GeoEl ems;
public: property System::Collections::Generic::List<GeoElem^>^ GeoElems {
System::Collections::Generic::List<GeoElem^>^ get() { return
%m_GeoElems; } // if compile error, try &m_GeoElems
}
Also GeoElem must be a public ref class.
.....
}

Jan 5 '07 #4
"raylopez99" <ra********@yahoo.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
My book says System::Collections::Generic classes are not CLS
compliant. So they are unsupported, with the usual caveats.
I'm afraid your book is wrong, Generics are CLS compliant.

Willy.

Jan 6 '07 #5
The book is Pro Visual C++/CLI and the NET 2.0 Platform by Fraser, p.
196 (2006 ed.) with a foreward by Stanley Lippmann. But the note does
say that in the future Generics might become CLS compliant "Personally,
I think the CLS rules will be expanded to include generics, but we
shall see."

RL

Willy Denoyette [MVP] wrote:
"raylopez99" <ra********@yahoo.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
My book says System::Collections::Generic classes are not CLS
compliant. So they are unsupported, with the usual caveats.

I'm afraid your book is wrong, Generics are CLS compliant.

Willy.
Jan 6 '07 #6
Nip
Hi
Thanks a lot :)

"Ben Voigt" <rb*@nospam.nospamwrote in message
news:OY****************@TK2MSFTNGP04.phx.gbl...
>
"Nip" <lu***@quantentunnel.dewrote in message
news:eW*************@TK2MSFTNGP06.phx.gbl...
>Hi
I want to access the Generic List of the following c++-class inside a
vb.net app. Is this possible/how can I do that?
Atm, I get the following error in the vb.net app: "Field 'GeoElems' is
of an unsupported type."

public ref class clsPhysik
{
.....
public: System::Collections::Generic::List<GeoElem^GeoElem s;

You're using C++/CLI stack semantics, which aren't supported by any other
language. You must exposed the tracking handle. Try:

private: System::Collections::Generic::List<GeoElem^m_GeoEl ems;
public: property System::Collections::Generic::List<GeoElem^>^ GeoElems {
System::Collections::Generic::List<GeoElem^>^ get() { return
%m_GeoElems; } // if compile error, try &m_GeoElems
}
Also GeoElem must be a public ref class.
>.....
}

Jan 6 '07 #7
raylopez99 wrote:
The book is Pro Visual C++/CLI and the NET 2.0 Platform by Fraser, p.
196 (2006 ed.) with a foreward by Stanley Lippmann. But the note does
say that in the future Generics might become CLS compliant "Personally,
I think the CLS rules will be expanded to include generics, but we
shall see."
Generics are available to any .NET language, the Microsoft-provided ones
as well as most 3rd party ones, such as RemObjects Chrome. That's
because generics are part of the .NET 2.0 runtime. Unlike templates,
which are compile-time constructs, generics are evaluated at runtime,
and are an integral part of the .NET 2.0 type system. In contrast,
C++/CLI templates are not accessible from other languages, and the CLS
does not know about them. Templates are replaced with non-generic
language constructs at compile time.

Reference: http://msdn2.microsoft.com/en-us/library/t357fb32.aspx

To be fair, however, the Fraser book was published very shortly after
the release of VS 2005, which implicates the author was probably using a
Beta build for the entire book, and referred to information that was
available at that time. You can't really blame him for that, and his
prediction actually came true.

Despite this small inaccuracy, the Fraser book is still a good
reference. It covers a very wide range of technology, and it turned out
to be pretty useful to me. The fact that the book was released so early
to the community far outweighs the disadvantages of those few possible
inaccuracies. You can always check the errata.

Tom
Jan 8 '07 #8
Thanks Tamas Demjen. I agree the Frazier book is useful, though full
of typos (but easily caught typos).

I did not know Generics were not templates (I assumed they were one and
the same). Learn something new everyday.

RL

Tamas Demjen wrote:
raylopez99 wrote:
The book is Pro Visual C++/CLI and the NET 2.0 Platform by Fraser, p.
196 (2006 ed.) with a foreward by Stanley Lippmann. But the note does
say that in the future Generics might become CLS compliant "Personally,
I think the CLS rules will be expanded to include generics, but we
shall see."

Generics are available to any .NET language, the Microsoft-provided ones
as well as most 3rd party ones, such as RemObjects Chrome. That's
because generics are part of the .NET 2.0 runtime. Unlike templates,
which are compile-time constructs, generics are evaluated at runtime,
and are an integral part of the .NET 2.0 type system. In contrast,
C++/CLI templates are not accessible from other languages, and the CLS
does not know about them. Templates are replaced with non-generic
language constructs at compile time.

Reference: http://msdn2.microsoft.com/en-us/library/t357fb32.aspx

To be fair, however, the Fraser book was published very shortly after
the release of VS 2005, which implicates the author was probably using a
Beta build for the entire book, and referred to information that was
available at that time. You can't really blame him for that, and his
prediction actually came true.

Despite this small inaccuracy, the Fraser book is still a good
reference. It covers a very wide range of technology, and it turned out
to be pretty useful to me. The fact that the book was released so early
to the community far outweighs the disadvantages of those few possible
inaccuracies. You can always check the errata.

Tom
Jan 11 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Abhi | last post by:
In the following hypothetical example I want to build a generic list of unique string items. How should I implement the pred function so that it returns true/false if target string exists in the...
5
by: majm | last post by:
I'm trying to implement strongly typed lists in the 2.0 framework. I'm using VS2005 beta 2. So far, System.Collections.Generic.List appears to be the ideal solution. However, the...
2
by: Nicolas Fleury | last post by:
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...
0
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting...
3
by: Peter Olcott | last post by:
How does not specify the sort criteria for Generic.List ?? The way that this is done in C++ STL is to implement operator<(), how is this done in C# and DotNet for Generic.List ???
2
by: Nip | last post by:
Hi I want to access the Generic List of the following c++-class inside a vb.net app. Is this possible/how can I do that? Atm, I get the following error in the vb.net app: "Field 'GeoElems' is of...
1
by: Kuldeep | last post by:
Framework: Visual Studio 2005, ASP.NET Programing Language: C#.NET I am using a Generic List Collection to fetch a particular master data from the database. Once collected, I use this Collection...
2
by: shapper | last post by:
Hello, I have an Enum and a Generic.List(Of Enum) 1 Public Enum Mode 2 Count 3 Day 4 Month 5 End Enum
3
by: cowznofsky | last post by:
I'm getting data in a generic list class, which I'm not going to change. I would like to use it as a datasource for a datagrid or a gridview, but it doesn't implement IEnumerable. I'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.