c++-cli

Using C++ Class DLL in C# Application

Hello, I have an unmanaged C++ DLL which merely exports a single class (not COM...it's just a simple C++ class) as its interface. I want to use this class in C# but am told that it cannot merely be imported into C#. What is the right way to use this class in my C# application? ...

Passing Unmanaged pointers in C++/CLI

I'm creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some of the function calls expect unmanaged pointers to be passed in. How do i pass them properly? Also, other functions expect a "this pointer" to be passed in as a void*. What's the right way to pass "this"? Here's my class definition... public ref cla...

Using C++, how can I instantiate WinForms form defined in C# library?

Hello, I'm sorry if this question has already been answered but I couldn't find it. I am trying to open a C# form when a function in a C++ program is called (the main program is in C++, the form is in C#, it is an empty form just to try how it works). I am using Visual Studio 2005 and I have both projects in my solution. The C# project ...

Is it possible to determine in which language a .NET Assembly was written ex post facto?

This started as a way to find C++/CLI and Managed C++ assemblies so that all classes internal to them could be tested to ensure all inherited methods were being reimplemented. I would like to add this as a build process step to ensure that it never happens again. Thinking about this problem also made me a bit curious as it would be int...

C# form in a C++ program

Hello. In my last question I asked about running a C# form in a C++ program. I got it working, but I am having problems. I will try to be brief. My C++ program must execute a C# form and execute some simple functions in it (increasing counters and showing them). However I do not know the best way to do this. I have the form initialized ...

How to create a global handle in C++

I am trying to use a C# class in a C++ project, but Visual Studio will only let me declare a handle (^) to a C# object in a local scope, just inside a function. The only way I got it working was declaring a global pointer to a handle: SUTAdapter::Form1^ *ptForm1; But if then I create an object inside a function and give its address to...

Can a static library contain managed resources?

In VC6 I had a large application linking with some DLLs and a static library "sharedlib". Each DLL would also link with this library. The app had its own resources, the DLLs had their own resources, and the static library also had its own separate resources. Of course I had to ensure that the static lib's resource IDs didn't clash anywh...

.NET assembly not loading from NTVDM

I have a VDD dll that's loaded by a DOS program running inside the NTVDM. This dll uses C++/CLI and references a .NET assembly. All in all, the loading process is something like this: NTVDM runs: prntsr.com which uses VDD RegisterModule to load: prnvdd.dll which references .NET assembly: prnlib.dll The prntsr.com...

Adding Existing Form to C++/CLI WinForms Project

I have two C++/CLI projects A and B in separate solutions. I use A for experiments/testing and move the tested code to B once I am finished testing. However, I find that on adding a windows forms class (header, cpp and resx) to project B, I am no longer able to use the visual forms designer of the IDE. How do I enable that? ...

Writing two dimensional array to file and reading two dimensional array from file using Visual C++

Hello, I'm new in C++.I made up 680x680 two dimensional array.And I tried to write it to txt file.Unfortunately,I can't write two dimensional array along its dimensions regularly. Also I want to read two dimensional array from txt file.My code is below.Could you help me ? /*Declaration 680 *680 multidimensional array*/ array< array< do...

Making C++ library Avaiable to .Net

I need to make a large c++ library avaiable for use in .Net languages such as C#. The library contains a large number of classes which can be broken into two groups. Refrence counted classes, which implement the IRefCounted abstract class and use a factory method to create them, and just plain classes using new/delete. In adittion ther...

C# to C++/CLI to C DLL System.IO.FileNotFoundException

I'm getting System.IO.FileNotFoundException: The specified module could not be found when running C# code that calls a C++/CLI assembly which in turn calls a pure C DLL. It happens as soon as an object is instantiated that calls the pure C DLL functions. BackingStore is pure C. CPPDemoViewModel is C++/CLI calling BackingStore it has a r...

Error Compiling C++/CLI Delegate call

The following code results in C3867 (...function call missing argument list...) and C3350 (...a delegate constructor expects 2 argument(s)...). What am I doing wrong? public ref class Form1 : public System::Windows::Forms::Form { public: bool IsEven(int i){ return (i % 2) == 0; } Form1(void) { ...

Designer Generated Code in Visual Studio C++/CLI Winforms Project

The Windows Forms Designer in C++/CLI projects generates both the declarations and definitions of all event handlers in the header file itself. The .cpp it generates is a mere stub which simply includes the generated header and stdafx.h. I feel that I could reduce compile times if I moved the implementation (i.e. definition) of all class...

System.Windows.Input not available to C++/CLI?

I'm working on a WPF app with a ViewModel in C++/CLI, so it can use legacy C code. I'm having trouble exposing the namespace System.Windows.Input to the C++/CLI code and wondering if this is because WPF doesn't really support C++/CLI? Do I really have to insert a C# layer in order to implement something like Josh Smith's CommandSinkBindi...

How to find the name of the current function at runtime? (C++)

After years of using the big ugly MFC ASSERT macro, I have finally decided to ditch it and create the ultimate ASSERT macro. I am fine with getting the file and line number, and even the expression that failed. I can display a messagebox with these in, and Abort/Retry/Cancel buttons. And when I press Retry the VS debugger jumps to the ...

Use C++ CLI template class in C#

Hi, I have the following class in C++/CLI and an explicit template instantiation for the int primitive.. template<typename T> public ref class Number { T _value; public: static property T MinValue { T get() { return T::MinValue; } } static property T MaxValue { T get(...

Offsetof macro with C++/CLI

The offsetof macro seems not to work under C++/CLI. This works fine in unmanaged C++, but throws "error C2275: 'Entity' :illegal use of this type as an expression" error in CLI. struct Property{ char* label; PropertyTypes type; unsigned int member_offset; unsigned int position; unsigned char bit_offset; }; st...

C++/CLI: Implementing IList and IList<T> (explicit implementation of a default indexer)

I am trying to implement a C++/CLI class that implements both IList and IList<T>. Since they have overlapping names, I have to implement one of them explicitly, and the natural choice should be IList. The implicit implementation of the indexer is: using namespace System::Collections::Generic; generic<class InnerT> public ref class MyL...

Do I just completely misunderstand how to use Visual Studio's 2008 profiler?

complaining { I always end up incredibly frustrated when I go to profile my code using Visual Studio 2008's profiler (from the Analyze menu option). It is one of the poorest designed features of VS, in my opinion, and I cringe every time I need use it. } I have a few questions concerning it's use, I'm hoping you guys can give me some ...