[Connect bug] VC++ 2010 : C++/CLI does not support variant delegates/interfaces
-
I posted that a day back. If any of you do use C++/CLI and this is an issue that you think is serious enough to require quick resolution, please vote the issue up. A higher number of votes will help them prioritize on the time/resources they want to spend on this issue. Thank you. To summarize, C++/CLI has not been updated to support variance in delegates and interfaces. C# 4.0 supports this and this limitation in C++/CLI will bring down its utility as an interop language. The following code does not compile in C++/CLI today, though the equivalent C# code will compile.
ref class Base {};
ref class Derived : Base {};
int main(array<System::String ^> ^args)
{
return 0;
}void FooInterfaces()
{
IEnumerable<Base^>^ base = gcnew List<Base^>();
IEnumerable<Derived^>^ derived = gcnew List<Derived^>();
base = derived; // <-- Error C2440 here
// IEnumerable<> is covariant so this should compile and does so in C# 4.0
}generic<typename T> void ShowItem (T item, Action<T>^ showFunc)
{
showFunc(item);
}void ShowBase(Base^ b) { }
void FooDelegates()
{
Derived^ d = gcnew Derived();
ShowItem<Derived^>(d, gcnew Action<Derived^>(ShowBase)); // <-- Error C3352 here
// Action<> is contravariant and this compiles in C# 4.0
}Thank you.
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
-
I posted that a day back. If any of you do use C++/CLI and this is an issue that you think is serious enough to require quick resolution, please vote the issue up. A higher number of votes will help them prioritize on the time/resources they want to spend on this issue. Thank you. To summarize, C++/CLI has not been updated to support variance in delegates and interfaces. C# 4.0 supports this and this limitation in C++/CLI will bring down its utility as an interop language. The following code does not compile in C++/CLI today, though the equivalent C# code will compile.
ref class Base {};
ref class Derived : Base {};
int main(array<System::String ^> ^args)
{
return 0;
}void FooInterfaces()
{
IEnumerable<Base^>^ base = gcnew List<Base^>();
IEnumerable<Derived^>^ derived = gcnew List<Derived^>();
base = derived; // <-- Error C2440 here
// IEnumerable<> is covariant so this should compile and does so in C# 4.0
}generic<typename T> void ShowItem (T item, Action<T>^ showFunc)
{
showFunc(item);
}void ShowBase(Base^ b) { }
void FooDelegates()
{
Derived^ d = gcnew Derived();
ShowItem<Derived^>(d, gcnew Action<Derived^>(ShowBase)); // <-- Error C3352 here
// Action<> is contravariant and this compiles in C# 4.0
}Thank you.
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
Looks like the other five users of C++/CLI have already voted with you.
-
Looks like the other five users of C++/CLI have already voted with you.
Damn you! :-D
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
-
Looks like the other five users of C++/CLI have already voted with you.
Joe Woodbury wrote:
Looks like the other five users of C++/CLI have already voted with you.
:D I love this kind of jokes, but C++/CLI is actually used (if not liked) by many more people than one would expect. Many people are falling in trap of "reusing the legacy C/C++ code while leveraging the productivity gains of .NET platform".
-
Joe Woodbury wrote:
Looks like the other five users of C++/CLI have already voted with you.
:D I love this kind of jokes, but C++/CLI is actually used (if not liked) by many more people than one would expect. Many people are falling in trap of "reusing the legacy C/C++ code while leveraging the productivity gains of .NET platform".
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
-
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
I've found it very useful for interop between Managed (C#,etc.) and legacy unmanaged C++ code. It's much more efficient than COM interop, and more flexible than pInvoke for scenarios where COM interop is not a choice). I would not use it for anything more significant than a thin interop layer, however.
-
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
Joe Woodbury wrote:
(If you've written C++/CLI, that makes three.)
I have.
_________________________ John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others." Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....
-
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
I've used it a little, though to be honest, I mostly try and skip .NET altogether and stick with C++ for most of my needs.
-
I've used it a little, though to be honest, I mostly try and skip .NET altogether and stick with C++ for most of my needs.
Matt Gullett wrote:
I've used it a little, though to be honest, I mostly try and skip .NET altogether and stick with C++ for most of my needs.
you and me both. :-D
_________________________ John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others." Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....
-
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
Well, yeah... It's easily the worst-supported (official) .NET language out there, so it doesn't get talked about much. At this point, I'm not interested in doing major work in a language that MS apparently wishes would die... But, it beats P/Invoke, so in the boundary between the C++ app and .NET components it has a home.
-
I've used it a little, though to be honest, I mostly try and skip .NET altogether and stick with C++ for most of my needs.
I also work mostly in C++. I do maintain a .NET library that interfaces with our core DLLs (with C entry points.) (For our XP embedded based system, I deliberately tried to write two utilities in .NET and abandoned the effort due to lack of support in the framework for what I needed to do. On top of that, the .NET version for one utility was over 10x bigger than the native version [and it wasn't even done!] and when pushing updates over cell that's a very big deal. One key utility was done in .NET and sometimes I want to strangle the guy who did that.)
-
I've found it very useful for interop between Managed (C#,etc.) and legacy unmanaged C++ code. It's much more efficient than COM interop, and more flexible than pInvoke for scenarios where COM interop is not a choice). I would not use it for anything more significant than a thin interop layer, however.
We are also using it like a middle tier when extending a MFC application with C#.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
I posted that a day back. If any of you do use C++/CLI and this is an issue that you think is serious enough to require quick resolution, please vote the issue up. A higher number of votes will help them prioritize on the time/resources they want to spend on this issue. Thank you. To summarize, C++/CLI has not been updated to support variance in delegates and interfaces. C# 4.0 supports this and this limitation in C++/CLI will bring down its utility as an interop language. The following code does not compile in C++/CLI today, though the equivalent C# code will compile.
ref class Base {};
ref class Derived : Base {};
int main(array<System::String ^> ^args)
{
return 0;
}void FooInterfaces()
{
IEnumerable<Base^>^ base = gcnew List<Base^>();
IEnumerable<Derived^>^ derived = gcnew List<Derived^>();
base = derived; // <-- Error C2440 here
// IEnumerable<> is covariant so this should compile and does so in C# 4.0
}generic<typename T> void ShowItem (T item, Action<T>^ showFunc)
{
showFunc(item);
}void ShowBase(Base^ b) { }
void FooDelegates()
{
Derived^ d = gcnew Derived();
ShowItem<Derived^>(d, gcnew Action<Derived^>(ShowBase)); // <-- Error C3352 here
// Action<> is contravariant and this compiles in C# 4.0
}Thank you.
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
I've voted there (I'm not using c++/cli though).
It's time for a new sig. Seriously.
-
I've voted there (I'm not using c++/cli though).
It's time for a new sig. Seriously.
Thank you :thumbsup:
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
-
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
Joe Woodbury wrote:
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
I used it for a project. I had a c++ core library to talk to a data source and then a code generator that made c++ and c++/cli classes to encode / decode different protocols. That code was then used to build c++ and c# clients of the data source. The main advantage was the core c++ library was reused by the c# clients as it was statically linked to the cli code library. It was even used on linux with mono.
-
Thank you :thumbsup:
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
For not using it? Why, is it the CLI in low supply these days? :-D
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
For not using it? Why, is it the CLI in low supply these days? :-D
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
Deyan Georgiev wrote:
For not using it? Why, is it the CLI in low supply these days?
Yeah big joke, funny guy! :rolleyes:
Regards, Nish
Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application
-
I've voted there (I'm not using c++/cli though).
It's time for a new sig. Seriously.
Rajesh R Subramanian wrote:
I've voted there
It's kinda sad how few people here did the same. It's only at 9 votes now and was 4 before I cast mine. The entire point of posting connect bug reports here is the I'll Scratch Your Back If You Scratch Mine Principle. It all falls apart if we don't vote each other's bugs to the TEOTWAWKI level necessary to have MS patch them in the next major release.
3x12=36 2x12=24 1x12=12 0x12=18
-
Other than Nish, here on CP, and myself, I don't know a soul who has written any C++/CLI code, even to try it out. I've written some C++/CLI code, just to see what it could do. Wasn't impressed and found the lack of interest by Microsoft to document and help you along to be a major show stopper. (If you've written C++/CLI, that makes three.)
/me puts his hand up. I've used it to expose .Net objects in Tcl, i.e. .Net Tcl extensions plus things that look like object. It astonished me just what a piece of engineering C++/CLI was. I couldn't believe it all worked as advertised. Typing with a baby in one hand is slow.
-
/me puts his hand up. I've used it to expose .Net objects in Tcl, i.e. .Net Tcl extensions plus things that look like object. It astonished me just what a piece of engineering C++/CLI was. I couldn't believe it all worked as advertised. Typing with a baby in one hand is slow.
Phil Martin... wrote:
Typing with a baby in one hand is slow.
Typing while holding a toddler who thinks keyboards are great fun is ever slower.