473,770 Members | 6,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::Collect ions::Generic:: List<GeoElem^Ge oElems;
......
}

Jan 5 '07 #1
8 2019
My book says System::Collect ions::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::Collect ions::Generic:: List<GeoElem^Ge oElems;
.....
}
Jan 5 '07 #2
raylopez99 wrote:
My book says System::Collect ions::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***@quantent unnel.dewrote in message
news:eW******** *****@TK2MSFTNG P06.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::Collect ions::Generic:: List<GeoElem^Ge oElems;
You're using C++/CLI stack semantics, which aren't supported by any other
language. You must exposed the tracking handle. Try:

private: System::Collect ions::Generic:: List<GeoElem^m_ GeoElems;
public: property System::Collect ions::Generic:: List<GeoElem^>^ GeoElems {
System::Collect ions::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********@yah oo.comwrote in message
news:11******** **************@ q40g2000cwq.goo glegroups.com.. .
My book says System::Collect ions::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********@yah oo.comwrote in message
news:11******** **************@ q40g2000cwq.goo glegroups.com.. .
My book says System::Collect ions::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.nos pamwrote in message
news:OY******** ********@TK2MSF TNGP04.phx.gbl. ..
>
"Nip" <lu***@quantent unnel.dewrote in message
news:eW******** *****@TK2MSFTNG P06.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::Collect ions::Generic:: List<GeoElem^Ge oElems;

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

private: System::Collect ions::Generic:: List<GeoElem^m_ GeoElems;
public: property System::Collect ions::Generic:: List<GeoElem^>^ GeoElems {
System::Collect ions::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
15182
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 generic list...is not clear to me. Any suggestions? System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(); foreach(string s in myAnotherArray)
5
5443
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 generic.List.IndexOf function doesn't appear to be invoking the contained class' CompareTo method. My understanding is that it should. The contained class (IssStruct) implements the IComparable and IComparable<T> interfaces. However, the List.Sort function...
2
5470
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 BaseClassInfo { ...
0
5929
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 problem serializing my stuff to XML when it comes to collections. I'm currently using .net2 with generic lists to prevent users putting all sorts of stuff in the arrays (Although im sure i'll be the only user of the classes but not the game, anyway)....
3
2275
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
308
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 an unsupported type." public ref class clsPhysik {
1
2627
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 to bind it to a DataGrid. Now that I am using a Generic List Collection to populate the DataGrid, say another user would insert a new record on to the same master data from a different machine, the updated data (along with the lastest inserted...
2
12334
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
13940
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 wondering if there's a simple technique that would allow me to get the data into the datagrid.
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.