c++-cli

How do I leverage a control from a C++/CLI project for use in my WPF application?

First of all, my knowledge of C++ is effectively zero. I'm a .NET developer but even my interop experience is minimal. I have found an example of a control written in C++/CLI that grabs and displays a webcam feed using DirectShow. I'd like to take this example and utilize it from my WPF application. I've tried (and butchered) several d...

OpenCV link problem

HI I switched from visual studio 2008 to 2010, now I have problem linking my lib files from opencv 1.1 I've added required libs and .h files. but I get following error: "Error 53 error LNK1181: cannot open input file 'cv.lib.obj' C:\Users..\SOLOUTION_NAME\PROJECT_NAME\LINK" ...

C++ re throw Exception gives error

I'm trying to catch a 'specific' exception (FormatException^ or OverflowException^) and then re throw it and catch it in the 'general' exception (Exception^) catch block. When run, I give it a format exception through input. I then get this error in a dialog box: "An unhandled exception of type 'System.FormatException' occurred in Futu...

C++/CLI code porting problem

hi, I'm trying to port a C++.NET (managed extensions) application to C++/CLI. However I'm not very strong with the syntax yet. What I'm trying to do is to create a wrapper for a C Dll file. To do this I'm using DllImport but I failed to found documentation on it's use. There are some problems due to changes of the syntax but I couldn't...

When to use __gc for classes and structs?

I am updating some old c++ code and am finding that many of the classes are defined as: public __gc class NameOfClass{ } I found a little bit of information about __gc here, but it seems to only come up with information for VS 2003. The MSDN documentation that came with my copy of VS 2005 indicates that __gc may not be in use anymor...

Creating html doc in CLI C++ with macros

From a native, external library, I get a header file with enum declarations: #define LIST(declare) \ declare(A, "aaa") \ declare(B, "bbb") \ declare(C, "ccc") \ Using it, I create a .NET enum: #define EXTRACT(p1,p2) p1, enum class Val { LIST(EXTRACT) }; Which works great. The result is Val.A, ... values. Now, I would like...

How to create file in Visual c++

I try create file in visual studio c++. But it now work, what is wrong? CreateFile("1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, ...

visual c++ create text file

How to create text file? CreateFile("1", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_FLAG_OVERLAPPED, NULL); throw 1>------ Build started: Project: test2, Configuration: D...

fastest/performance approach to send large managed Bitmap object to unmanaged/native function

Hi to all, I am excited to be a part of the forum :) my first post ! I am posting this so that many can benefit from it. My question: what is the fastest/performance approach to send large managed Bitmap object to unmanaged/native function ? I will be using C++/CLI, (VS 2008, .NET 3.5) for that purpose One Approach: pin_ptr use pin_...

is it possible to return two vectors from a function?

Im trying to do a merge sort in cpp on a vector called x, which contains x coordinates. As the mergesort sorts the x coordinates, its supposed to move the corresponding elements in a vector called y, containing the y coordinates. the only problem is that i dont know how to (or if i can) return both resulting vectors from the merge functi...

C++ Interop: How do I call a C# class from native C++, with the twist the class is non-static?

Hi, I have a large application written in native C++. I also have a class in C# that I need to call. If the C# class was static, then it would be trivial (there's lots of examples on the web) - just write the mixed C++/CLI wrapper, export the interfaces, and you're done. However, the C# class is non-static, and can't be changed to sta...

What is the C++/CLI equivalent to a VB6 Collection?

I already tried ArrayList^ and VB6 gives me a 'Type mismatch' error. I don't see a C++/CLI 'Collection' or 'List'. So what is the equivalent, if there is one? ...

C++/CLI pointer issue = fun!

I've been converting a bunch of old C++ code into C++/CLI code, and I think I've coded myself into a corner. My goal was to take an unmanaged c++ library and a bunch of header files and expose their functionality to a C# solution. From reading on the internet, the standard way to do this is to: Create two c++ classes: one managed, th...

Using MinGW/GCC built DLL in a Visual Studio 2010 C++/CLI project

I have a communication library built on top of Qt and Google Protocol Buffers. It's currently being built with MinGW/GCC on Windows. My goal is to use the same library in C# on .NET, with the help of a thin wrapper on top using C++/CLI (bridging the unmanaged code with managed code). I tried using the MinGW produced DLL directly in my ...

C++ scanf/printf of array

I've written following code: int main() { double A[2]; printf("Enter coordinates of the point (x,y):\n"); scanf("%d,%d", &A[0], &A[1]); printf("Coordinates of the point: %d, %d", A[0], A[1]); return 0; } It's acting like this: Enter coordinates of the point (x,y): 3,5 Coordinates of the point: 3, 267...

How to map Qt Signal to Event in Managed C++ (C++/CLI)

I'm writing a wrapper in .NET (C++/CLI) to be able to use some native C++ Qt code in .NET. How can I map a Qt signal into a managed .NET event, so that when my Qt code fires off a signal, I can bring this forward to the .NET code. My Managed class defines the event, but if I try to use the normal QObject::connect method to hook up to th...

Marshal void* to array<byte>^

I am looking to write a void* buffer to a MemoryStream in a C++/CLI. As I don't think this is possible directly, alternatively I would like to convert this buffer to an array<byte>^ in order to be able to call Stream.Write(). I've looked at Marshal but then I am having trouble coverting void* to System::IntPtr. Any help is appreciated. ...

Using Manged class objects in Unmanaged

Hi, Im including one thirdparty reference to my coding.But when i use it my coding it shows error. My code: In TagInfo.h ref class Globals { public: static DUAL_INOUTLib::DualInOut^ objVM; }; Im using it in my coding as In TagInfo.cpp void CTagController :: ReceiveLivePoints() { float PV,SV,MV,P,I,D; ...

C++/CLI : Why can't I pass Strings by reference?

Why doesn't Microsoft's C++/CLI allow me to pass strings by reference? I received the following error: C3699: '&': cannot use this indirection on type 'System::String' ...

Visual C++ Test project doesn't display standard output

I created a Visual C++ test project which contains printf statements. Unfortunately, I can't find a method to view the output of this. It isn't included in the output window. Any suggestions? ...