c++-cli

How do I call C++/CLI from C#?

你说的曾经没有我的故事 提交于 2019-12-17 02:54:12
问题 I have a class implemented in C++ that's responsible for the arithmetic computation of the program, and an interface using WPF. I process the input with C# but then how can I use my C++ class? I've seen some comments about making a managed C++ wrapper class to interact with it, but I don't know where to start. Nor do I know how I'd go to compile it along with all the other code. I can't really find a tutorial on this, and the stuff google shows on managed C++ doesn't really seem helpful.

Is it possible to include code only inside one class?

左心房为你撑大大i 提交于 2019-12-14 04:22:16
问题 I hope I can explain myself. Supose I have next: File "A.h": #include "C.h" public class A{ // Some code... } File "B.h": #include "A.h" public class B{ A a = new A(); //With this line I mean I'm using one instance of "A" inside "B.h" //Some code... } Is it possible to include "C.h" ONLY inside "A.h"? My problem is that the code I've included is giving me a lot of conflicts with usual functions. It's not an option to correct conflicts one by one, because there is a huge set of them. Also, my

HashMap : Dealing with Managed objects C++

*爱你&永不变心* 提交于 2019-12-14 03:15:18
问题 I guess it's kind of a stupid question but here is my problem : I want to have a hash_map<int, Object^> as an attribute of my object BigObject , which is written in managed C++. So I have to declare a pointer, hash_map<int, Object^>* hash because I cannot declare explicitely native object in managed code. How can I insert an object ? the hash_map[] won't work with a pointer, and I cannot make insert work (I cannot use a std::pair<int, Object^> because Object is managed... Thanks a lot 回答1:

C++/CLI: make public for template type

那年仲夏 提交于 2019-12-14 02:21:49
问题 AFAIK #pragma make_public supports only native non-template types. But, is there some other way to make template type as public? 回答1: No. But read here for some workarounds: Best workaround for compiler error C2158: make_public does not support native template types http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/b43cca63-b0bf-451e-b8fe-74e9c618b8c4/ 回答2: Templates don't have external linkage. Not in native C++, not in C++/CLI either. You solve it the same way, put them in a

members of class being overwritten when new instance created c++/cli

核能气质少年 提交于 2019-12-13 23:54:32
问题 I have tried to implement the following: 1) Create a class that contains managed arrays 2) Create three instances of this class 3) Fill those arrays from three different data files. 4) Perform an analysis of this data I have been able to compile code that performs task numbers one and two, however when I fill the arrays of the subsequent instances they seem to overwrite the data of the previous ones. I have tried to use a structure instead of a class. I have tried to use native arrays instead

A fatal error has been detected by the Java Runtime Environment: JNI (Internal Error)

时间秒杀一切 提交于 2019-12-13 21:14:51
问题 I am trying to call VB DLL method in Java. I have succeeded in calling simple Hello World method. Now I try to call a method that takes String as input and returns String as output. The Wrapper DLL is compiled successfully. But on running the Java code, the error A fatal error has been detected by the Java Runtime Environment: Internal Error (0xe0434352), pid=3668, tid=1124 On searching, I found that following error comes mostly due to error in native code, which I can't figure out. Following

Visual C++ (C++/CLI) Forward Declaration with Derivative Classes?

China☆狼群 提交于 2019-12-13 20:50:29
问题 Okay, so I'm running into trouble with Forward Declarations in Visual Studios C++ (C++/CLI). The code is as follows: A.h #include "B.h" #ifdef B_H #pragma once public ref class A : public base_class //base_class is public, memory managed { B^ b; } #endif B.h #define B_H #pragma once ref class A; ref class B { A^ a; } #include "A.h" The #ifdef/#pragma guards should keep be keeping a *.h from being read twice, and forcing b.h to be read first, and from the compiler output I'm pretty sure they

Inheriting from native C++ in C# and passing the inherit class backward to c++

为君一笑 提交于 2019-12-13 15:42:28
问题 I've an engine in a native C++ dll and I need to use it in a C# project. I'm totally new on doing that, but I've been googling for hours and now I know more or less how to achieve it. I know I've to write a C# or C++/CLI wrapper class. But I haven't found how to wrap some aspects of the dll C++ class. The engine has class CEntity whith this important part: class CEntity { void SendMsg(CEntity *receiver); virtual void ReceiveMsg(MSG msg); } That works as follows: A inherit class from CEntity

Casting a CLR type to void* and back

本小妞迷上赌 提交于 2019-12-13 14:41:19
问题 How to properly convert a CLR type, say Foo^ , to void* and back some time later? The scenario is, I have some unmanaged code in a DLL that can be summarized as class Handler { void* _obj; void (*_call)(void* obj, int detail); void handle_event() { _call(_obj, 1234); } public: void set_object(void* obj) { _obj = obj; } void set_callback(void(*callback)(void*,int)) { _call = callback; } }; I want to store a CLR object in the Handler 's _obj field. How to implement it, taking into account that

Floating Point Representation in Debugger in C vs C++(CLI)

你。 提交于 2019-12-13 14:06:33
问题 A little background : I was working on some data conversion from C to C# by using a C++/CLI midlayer, and I noticed a peculiarity with the way the debugger shows floats and doubles , depending on which dll the code is executing in (see code and images below). At first I thought it had something to do with managed/unmanaged differences, but then I realized that if I completely left the C# layer out of it and only used unmanaged data types, the same behaviour was exhibited. Test Case : To