c++-cli

What does the caret mean in C++/CLI?

I just came across this code and a few Google searches turn up no explanation of this mysterious (to me) syntax. Hashtable^ tempHash = gcnew Hashtable(iterators_); IDictionaryEnumerator^ enumerator = tempHash->GetEnumerator(); What the heck does the caret mean? (The gcnew is also new to me, and I asked about that here.) ...

C++/CLI from MFC extension DLL

I have an MFC application that uses several MFC extension DLL's. I want this app (and several other similar apps) to be able to access some parts of the .net framework. I wrote a C# library to do the .net work I want and was hoping to be able to write an MFC dll to hide all the C++/CLI code from my apps. The apps would stay as pure MFC a...

C++/CLI Reference Variable

void f(cli::array<PointF> ^points){ PointF& a = points[0]; // and so on... } Compile error at line 2. .\ndPanel.cpp(52) : error C2440: 'initializing' : cannot convert from 'System::Drawing::PointF' to 'System::Drawing::PointF &' An object from the gc heap (element of a managed array) cannot be converted to a native re...

Mixing MFC and WPF: Modal Dialogs

I'm adding C# WPF dialogs to an existing C++ MFC app, using a C++/CLI interface layer. I've got things working, except I'm having a problem with modality. For example: MFC app shows a WPF dialog using ShowDialog. Works as expected. That WPF dialog shows a MFC dialog using DoModal. The WPF dialog is hidden behind the base C++ app, and i...

Is there any advantage to using C++/CLI over either standard C++ or C#?

I'm not seeing any real advantages, other than the fact that you have a C++ syntax, and with it, things like pointers and destructors. ...

Pass value to form in .Net

I want to pass an integer value to a form in .Net so that it can load the right data. I'm using this so that when I double click on a record in a list, a form opens with the data from that record loaded so it can be edited. What is the best way to do this? Should I create a property and set it before calling the Show() method, or should ...

C++/CLI Books

Can anyone recommend any specific books on C++/CLI, particularly with reference to .NET and Visual Studio. It seems to me that there is very little out there, a few APress books with a couple of comments each on amazon. I'm looking in particular for something that isn't an introduction to C++, but something more Microsoft specific. Than...

Signing a mixed mode C++ assembly

Can you sign a C++ CLI application that is partially managed and partially unmanaged? ...

Event handling in Visual C++

There are two pictureboxes with two different images. If I click on one picture box, the image in it should be cleared. To make the matters worse, both of the picture boxes have only one common event handler. How can I know which picturebox generated the event? I would appreciate source code in Visual C++.net I need to know what to wr...

C++ CLI structure to byte array

I have a structure that represents a wire format packet. In this structure is an array of other structures. I have generic code that handles this very nicely for most cases but this array of structures case is throwing the marshaller for a loop. Unsafe code is a no go since I can't get a pointer to a struct with an array (argh!). I c...

Debugging in a dll with both managed / unmanaged code fails in VS 2005. Why?

I want to debug a piece of code written in C++. The problem is that the dll is mixed - it contains both C++ and CLI (managed C++). The environment is VS 2005. My entry point is a very simple executable project, written in C++ that just starts the code in the mixed dll. The problem is that: if I let the "Debug type" as Auto for both...

where do I initialize a managed C++\CLI dll

What is, or should I ask, is there, an equivalent to DllMain when creating a dll using C++\CLI? Are there any restrictions on what cannot be called from this initialization code? ...

MSVC++ Linker warning when using PIMPL idiom in C++/CLI

I am writing a .NET assembly using C++/CLI (version 9.0), and I would like to use the PIMPL idiom to avoid putting unnecessary stuff in my public header. Unfortunately, when I try to forward declare a class, and then use a tracking handle to it, I get Linker warning 4248: warning LNK4248: unresolved typeref token (0100000E) for 'MyN...

How to use System::Threading::Interlocked::Increment on a static variable from C++/CLI?

I would like to keep a static counter in a garbage collected class and increment it using Interlocked::Increment. What's the C++/CLI syntax to do this? I've been trying variations on the following, but no luck so far: ref class Foo { static __int64 _counter; __int64 Next() { return System::Threading::Interlocked::Incre...

Unit testing CLI/MFC Application

Hey all. I have CLI/MFC application and I would like to begin to learn how to unit test with it. I have VS2008 Pro. If possible, I would like to use the built in unit testing. Thanks for your input! ...

C++/CLI and the remoting security

Hi everyone, I have a c++/cli dll wrapping around some native code, and I'm trying to make an IPC server around this dll using the WellKnownServiceType. I wrote the entire thing in this fashion: Native code->C++/CLI dll->C# server program <---IPC link---> C# client I'm running into security problems when I do it this way: The client ...

Why can C# do this and C++/CLI cannot?

.NET Framework 3.5 comes with all the LINQ goodies, and also includes predefined generic Func and Action delegates. They are generic for up to 4 arguments. I am writing a C++/CLI project that (unfortunately) uses VS 2005 and must only rely on the standard 2.0 assembly set (so no System.Core). I tried defining my own generic delegates (i...

Why is "array" a reserved word in C/C++?

Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for? ...

Using .NET class from native C++ using C++/CLI as a 'middleware'

I have to use a class/assembly made in C# .NET from native C++ application. I suppose I need to make a wrapper class in C++/CLI, that would expose native methods in header files, but use .NET class as needed. Thing that's unclear to me is how to convert data types from .NET to standard C++ types. Does anybody have some sample code to l...

Strong Name Validation Failed

Two machines. Both with .NET 3.5 and the VS 2008 VC++ SP1 redistributables A single exe which uses two signed DLLs, one in C++/CLI and one in C# The exe loads and runs fine on one machine. On the other, I get "Strong Name Validation Failed" on the C++ executable (HRESULT 0x8013141A) Any ideas? ...