c++-cli

Convert array<int^>^ to int*

how can I convert array<int^>^ to int*? ...

Why is my destructor never called?

A CustomPropertyList class is created in my form constructor. form(String ^s) { InitializeComponent(); CustomPropertyList ^propertyList = gcnew CustomPropertyList(s); ... The CustomPropertyList class has a destructor CustomPropertyList::~CustomPropertyList() { if (MessageBox::Show("Do you want to save your changes?","Edi...

Why does my program work only in Debug mode?

I'm using Visual Studio 2008, with .net framework, C++/CLI. My program only runs in debug mode (even when run from explorer) - but in release mode it says program has stopped working. (But if I press F5 when it release mode it runs fine) All the settings are identical. What could it be? does anyone have any suggestions please? ...

Consuming Web Service from C++/CLI

Hello, is it possible to consume web service (written in c#, ... I don't have control over it, just URL to it's .asmx) from C++/CLI? There is no 'add web reference' in C++/CLI project :( ...

What book should I read to learn about writing server (sockets, TCP) programs in C++/CLI?

I recently finished this book on Managed C++, and found it very interesting... But I realize the topic is woefully out-of-date now, with the advent of C++/CLI. So I'm looking for recommendations on a new book to read, something to update my knowledge of C++ and .NET. I'm especially interested in writing server applications (using socke...

array of pin_ptr<Type>

I need to marshal an array of String^ to call a unmanaged function that expects an array of BSTRs. On MSDN I found the article How to: Marshal COM Strings Using C++ Interop with this code sample: // MarshalBSTR1.cpp // compile with: /clr #define WINVER 0x0502 #define _AFXDLL #include <afxwin.h> #include <iostream> using namespace st...

Convert String^ to const char* [vs c++]

I have a String^1 and I need to convert it to const char* and c_str() does not work as it is not a member of System::String. Is there a simpler way to do this other than this method? I am only doing this once and it is from an openFileDialog->Filename, so the input will not be anything complex. I am using Visual Studio 2008. Thanks ...

Cross-platform native/managed interface

I have a few native C++ libraries and such that I need to expose to managed (C#, in this case) code. I need to get as much speed out of it as possible. I would like to use some classes to simplify the interaction, which means mixed code, but that's not a requirement. What is a requirement is that it be cross-platform compatible, to Win...

C++/CLI: Is overloading on return type only possible ?

If I understand well, in C#, it is possible to do public class X : ICloneable { public X Clone() { ... } object ICloneable.Clone() { return Clone(); } // This calls the above } according to this thread. This kind of overloading is forbidden in C++, since it only depends on the return type. Now, I would like to do this exact t...

Can Reflector reverse engineer a C++/CLI application

I want to build an application being able to use .Net classes. If I go for C# I know that some tools like Refactor is able to reverse engineer the code (until I don't pay very expensive tools capable of avoiding this). Do you know if the same applies when my application is developed in Visual C++ ( with /clr ). You can easily mix Manage...

Restrict Text Box to only accept 10 digit number C++/CLI

I have a Text Box that is a System::String^, I need to confirm that this only accepts 10 digits numbers and no letters, symbols, etc. How would I implement this in C++ visual studio? Do I need to convert the contents to a std::string first? ...

What is the "^" symbol in C++?

Has a new symbol joined the C++ language specification while I was sleeping under a rock? I just encountered the following question: http://stackoverflow.com/questions/3621649/restrict-text-box-to-only-accept-10-digit-number-c Which suggests that the '^' symbol is somehow part of C++ (not in the legacy meaning of a bitwise-XOR) Is th...

Possible to elegantly convert std:vector to cliext::vector or cli::array<T>?

How's that for a catchy title? I need to convert back and forth from a CLR compliant type, like an array, and a std::vector type. Are there any adapter methods out there, or should I just keep copying it in and out each time I call one of my native methods? There are some interesting methods for converting between the cliext STL var...

C++/CLI 64-bit COM

I have a C++/CLI assembly that wraps a native 32-bit dll. The assembly is used both from .Net and COM (office). Now I have a customer that runs 64-bit office. Is it possible to create a C++/CLI assembly that uses a native 32-bit dll and exports a 64-bit com interface? ...

Abstract Sealed Classes

Just a small question about c++/cli. Abstract classes have abstract methods to be implemented by derived classes, sealed classes dont allow inheritance. So why we have some classes in .NET base class library defined as abstract sealed, and you can find plenty .. ??! ...

System.AccessViolationException from unmanaged code?

Hi, I'm writing this library that implements some basic audio player features in C++/CLI via the Media Foundation framework that will be consumed by managed code. I can play audio, stop, pause, etc just fine. For anyone who is not familiar with Media Foundation, the media session posts events that you can handle for notifications. Th...

How to register a non-static callback as a function pointer in a C++/CLI environment ?

We have a C++/CLI class, let us call it class A, from which we would like to register a non-static callback ("MyNonStaticCallback") into an unmanaged C++ class (class B). e.g. void MyNonStaticCallback(void* ...) { // Raise a C# event from this code } // Register callback into class B myClassBInstance->RegisterCallback(..., &MyNon...

marshal_as, strings and fields vs. properties

Hello, #include "stdafx.h" #include <string> #include <msclr/marshal_cppstd.h> ref class Test { System::String^ text; void Method() { std::string f = msclr::interop::marshal_as<std::string>(text); // line 8 } }; This code when compiled with VS2008 gives: .\test.cpp(8) : error C2665: 'msclr::interop::marshal_as' :...

Using Win32 libraries through Windows Form elements

I have created a simple GUI using Windows Forms in visual C++ 2008. There is a button in the GUI. When the button is pressed I want mouse cursor to point at coordinates (0,900). I have created separate header and c++ source file that sets the cursor position to specified location (x,y). For this I have used Win32's SetCursorPos() functio...

RAII in C++/CLI

I'm used to the C++ RAII facilities, and I want to use RAII the right way with managed code in C++/CLI. Herb Sutter and Microsoft both tell me this is the best practice. I have something like this: ref struct Managed { // No default constructor Managed( /*...*/ ) { /*...*/ } ~Managed() { /* Important non-managed resource re...