managed-c++

Managed code in WinPE

If I want to run a program in windows PE (Vista or 7) am I not allowed to use any level of managed code? Can I only have c++ code that doesn't reference any dotNet code? How can I interact with windows? Do I have to use user32.dll type files to carry out various operations? ...

C++/CLI -- 0xc000007b (INVALID_IMAGE_FORMAT) with /clr option on

Hi; I'm trying to build a C++/CLI executable to which I statically link ffmpeg (libavcodec, libavformat, libavutil & swscale). It works fine if I build it normally (without /clr, so no CLR support), it works. However, when I add CLR support, it won't start up with a 0xc000007b. A "Hello World" C++/CLI app runs fine, though. Supposedly t...

Why public ref in c++ class definition

Hi, First of all I want to make clear that 'm all new to C++, so this might be a simple and somewhat obvious question. In the C++ book I'm reading called C++ Primer, a class is defined by writing: class classname{ public: private: }; However, in VS2008 the compiler didnt like this. But by adding public ref before class, as in: pub...

Problem in double.Parse in Managed C++

I am getting a weird problem while parsing a double value in managed C++. It may be that I am doing something wrong. When I do: double value = 0.006; result = Math::Parse( value) The output of result is 0.006000000000001. Why it is appending a 1? Also when I go an round the value to 5 decimal places, it fails. I am doing: result...

Why doesn’t WPF support C++.NET - the way WinForms does?

As a C++ stickler, this has really been bugging me. I've always liked the idea of the "language-independant framework" that Microsoft came up with roughly a decade ago. Why have they dropped the ball on this idea? Does anyone know the reasoning behind it? ...

Global objects of Managed types

Is there any way to declare/define global/static objects of managed types ? ...

Managed C++ vs C# Performance for CodeModel and other COM Objects

I am creating an extension for Visual Studio 2008, and because I didn't want to write my own parser for C++ (I'm not masochistic) I am using VCCodeModel. Getting a simple field from these COM objects takes orders of magnitude more time than any of the other operations I am doing, and since I am drilling down to the method level of very ...

Create IDispatch .NET COM class where content is available only at runtime.

I'm currently in the process of moving some code from native C++ to managed C++ (pure). The code involves interacting with Windows Active Scripting. Currently our native code provides a class called 'ObjectDispatch' which implements 'IDispatch' (using ATL). This class implementation queries our own native class 'Object' at runtime to det...

What is a callback? What is it for and how is it implemented in for example C++.

Hi, I realise this is a newbie question, but as I'm trying to learn C++ I'm stumpling upon this expression "callback" frequently. I've googled it and checked wikipedia, but without finding a good explination. I am familiar with some Java and C#, but how unlikely it sounds, I have never really understood what a callback means. If someon...

C++/CLI - Help with pin_ptr

Hello, I'm writing a wrapper app that uses some unmanaged functions and I'm using a lot of pin_ptr. My question is, most of the time I use pin_ptr inside a method call, and the pin_ptr variable is declared also inside the method call. When the code goes our of the method, can I have any problem because it's no longer pinned? Should I mo...

Visual Studio 8: Build Times in mixed-mode assemblies.

I have an C++/CLI assembly consisting of approximately 50 source files. The code in this assembly links statically to a number of C++ libraries to do various 'heavy-lifiting' type tasks. I am using Visual Studio 8 (2005) SP1 to build this assembly. Building just this assembly (without dependencies, etc) via 'Project Only'->'Rebuild On...

C#'s lock() in Managed C++

Does managed C++ have an equivalent to C#'s lock() and VB's SyncLock? If so, how do I use it? ...

Is it possible for an unmanaged C++ app to only load the CLR when it needs managed types?

More to the point, I have a native C++ application, that may never need to use managed types. I would like the CLR to remain unloaded until I the codepath that actually depends on managed types is actually hit. I was trying to accomplish this using the /clr switch in Visual Studio 2005, but as far as I can tell as soon as I use that swi...

Performance differences between P/Invoke and C++ Wrappers

In the process of learning P/Invoke, I asked this previous question: How to P/Invoke when pointers are involved However, I don't quite understand the implications of using P/Invoke in C# over creating a wrapper in Managed C++. Creating the same DLL using P/Invoke in C# definately resulted in a cleaner interface since I could use DL...

how do you call a managed (c#) function from c++?

I have a c# dll project (my_cs_dll.dll) which defines a static class with a static member function. namespace Foo { public static class Bar { public static double GetNumber() { return 1.0; } } } I also have a c++ dll project which is using /clr. #using <my_cs_dll.dll> double get_number_from_cs() { return Foo::Bar...

Array of Objects/Classes fails for user defined Class

Hello, I am hoping someone with some more C++ knowledge might be able to help me. I am trying to create an array of objects in C# from a Class I've created in a Managed C++ DLL. I haven't any clue what is going on. I am able to run the application and build it setting up the array of classes appears to work perfectly fine but when I cal...

Cleanest Method for copying Native DLLs in a .NET Project

I have a C# GUI application that references a Managed C++ project, which requires 7 native C++ DLLs. I'm looking for the cleanest method for copying these 7 DLLs to the final project output. What works Add all DLLs to the C# applications, specifying: Build Action == "Content" Copy To Output Directory == Copy Always" This will ...

How do I use Ruby 1.9 with Managed C++?

I'm trying to create a dot net library to use ruby, for the sake of this, I'm linking ruby's static library but I'm getting some LNK error. I'm using Visual Studio 2008, thanks in advance. ...

How do I call Foo(long[][]) (C#) from Managed C++ (old syntax)?

I've got existing C# code with signature of Foo(long[][] longs) which I need to call from Unmanaged C++ (not C++/CLI). I just can't seem to figure out the right combination of __gc[] and __gc* to make the compiler happy. With C++/CLI, this is straight-forward: std::vector<__int64> evens; evens.push_back(2); evens.push_back(4); evens.p...

Clutter in mixed C++/CLI assemblies

Is there any way to hide native placeholder definitions from the managed metadata (visible in Reflector)? I'm creating a mixed-mode C++/CLI assembly containing some files compiled with /clr and some compiled without. I'm using boost and MFC in the native code only, but the boost/MFC headers still need to be #included into the managed c...