c++-cli

Is C++ CLI a superset of C++?

£可爱£侵袭症+ 提交于 2019-11-28 07:08:35
问题 Would a C++ CLI compiler be able to compile some large sets of C++ classes without modifications? Is C++ CLI a superset of C++? 回答1: technically no, but depending how standard the C++ code is, you'll probably be just fine. when you get into windows stuff you may run into issues. I compiled the whole game engine we use at work in C++/CLI once and it worked just fine. A colleague did the same for all of mozilla and no such luck. 回答2: According to Wikipedia: C++/CLI should be thought of as a

How do I pass the address of a c++ method in win32 app to a c# method with Action delegate parameter method

一个人想着一个人 提交于 2019-11-28 07:06:14
问题 I have a win32 application using a C# library . The C# library has a method where the Action<T> delegate is a parameter as shown: public NetSocket(Action<int, int, string> action) I have a ref class in the win32 application with a method that matches the Action delegates signature. How exactly do I pass this method as the Action parameter in the NetSocket method listed above? Ben your solution seem to work but there was a compile error on matching the System:Sting ^ input parameter of the

afxwin.h issues in Visual Studio 2015 Windows Form App

醉酒当歌 提交于 2019-11-28 07:05:36
问题 A while ago i wrote a C++ CLI Windows Form app, which compiled fine in Visual Studio 2013. Now i wanted to recompile it in Visual Studio 2015 Update 1 but i'm facing a problem, and after hours of tests i figured out the culprit is afxwin.h . TL;DR - Is there any way i can use stdafx.h (so afxwin.h and all other imports coming with it) in a Windows Form app compiled with Visual Studio 2015 without having the app crash upon start? Here's how to reproduce the same issues i'm facing in my app.

Tracking reference in C++/CLI

拈花ヽ惹草 提交于 2019-11-28 07:04:21
Can someone please explain me the following code snippet? value struct ValueStruct { int x; }; void SetValueOne(ValueStruct% ref) { ref.x = 1; } void SetValueTwo(ValueStruct ref) { ref.x = 2; } void SetValueThree(ValueStruct^ ref) { ref->x = 3; } ValueStruct^ first = gcnew ValueStruct; first->x = 0; SetValueOne(*first); ValueStruct second; second.x = 0; SetValueTwo(second); // am I creating a copy or what? is this copy Disposable even though value types don't have destructors? ValueStruct^ third = gcnew ValueStruct; third->x = 0; SetValueThree(third); // same as the first ? And my second

Sharing an enum from C#, C++/CLI, and C++

非 Y 不嫁゛ 提交于 2019-11-28 06:50:56
I have a library that consists of three parts. First is native C++, which provides the actual functionality. Second is a C++/CLI wrapper/adaptor for the C++ library, to simplify the C# to C++ transition. Finally I have a C# library, which invokes the C++ library through the C++/CLI adaptor. Right now there I have two sets of parallel enum definitions, one stored in a .cs file and the other in a .h file. This poses a double problem: I have dual maintenance. I must always synchronize changes of an enum in both file locations. The namespace used by both enums should be identical but the C++/CLI

How to access class in C++/CLI from C#?

浪尽此生 提交于 2019-11-28 06:33:31
I am writing a GUI tool in C# to parse and display the data output of another program written in C. In order to parse the data I need to know the data structures which are specified in a number of C header files. Thus I need to incorporate those C header files into my C# project. My questions are: 1) After some research I came to conclude that the best way is to create a new C++/CLI project in my solution, import the C header files into this new project, write some C++/CLI classes that act as thin wrappers for the data structures defined in the C header files, then reference the C++/CLI

What is gcnew?

左心房为你撑大大i 提交于 2019-11-28 06:09:17
I stumbled across this code and am too proud to go and ask the author what it means. Hashtable^ tempHash = gcnew Hashtable(iterators_); IDictionaryEnumerator^ enumerator = tempHash->GetEnumerator(); What is gcnew and how important is it to use that instead of simply new ? (I'm also stumped by the caret; I asked about that over here .) Steven A. Lowe gcnew is for .NET reference objects; objects created with gcnew are automatically garbage-collected; it is important to use gcnew with CLR types Joel Coehoorn gcnew is an operator, just like the new operator, except that you don't have to delete

Creating a pure MSIL assembly from a C++/CLI project?

孤街浪徒 提交于 2019-11-28 06:06:12
I am trying to create a pure MSIL assembly from a C++/CLI project using /clr:pure and /clrimagetype:pure flags, however, the output assembly specifically targets x86. Am I missing anything that might be preventing my project to be compiled as MSIL only? Glenn Slayden You can create an AnyCPU dll with C++/CLI , but in the simplest case, you will not be able to use MFC, ATL or the CRT. However, if you just want to write pure managed .NET code in C++/CLI, including managed pointers (which /clr:safe does not allow), and get the more elaborate code optimization of the C++/CLI compiler, read on: For

How to link C# and C++ assemblies into a single executable?

不问归期 提交于 2019-11-28 06:04:47
I have VS2008 solution containg a project that generates a C# executable that references a project that generates a dll containing both C++/CLI and unmanaged C++. I would like to merge these into a single executable, as the C++ dll contains security code that I want to embed in the main executable. I cannot use ILMerge, as the dll contains both managed and unmanaged code. The suggested solution seems to be to use link.exe to link the C# assembly with the C++ object files. This is what I am trying to do. I manually edited the project file for the c# executable to generate a netmodule. I added a

Copy from const char* to a byte array C++/c# interop Marshal::Copy

可紊 提交于 2019-11-28 05:34:19
问题 I'm trying to send an image from C++ to C# with an interop (marshaling) of C++ managed. image->getStream() return a const char* from a string. I'm having exception with my Marshal::Copy function. An unhandled exception of type 'System.AccessViolationException' occurred in mscorlib.dll Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Am I doing the right thing for the copy from a const char* to a byte array ? My dll