c++-cli

Pass an argument by reference in C++/CLI so re-assignment affects the caller

谁都会走 提交于 2019-11-29 17:25:33
问题 Probably this is not a difficult question, but I am always a little bit confused on how to treat String type as an argument in Visual C++. I have the following to functions: void function_1(String ^str_1) { str_1 = gcnew String("Test"); } void function_2() { String ^str_2 = nullptr; function_1(str_2); } After calling function_1 , str_2 is still equal to null , but what I want to achieve is that str_2 is equal to Test . So, how can I achieve that the content of str_1 is passed to function_2 ?

C++/CLI Resource Management Confusion

别等时光非礼了梦想. 提交于 2019-11-29 17:18:31
问题 I am extremely confused about resource management in C++/CLI. I thought I had a handle (no pun intended) on it, but I stumbled across the auto_gcroot<T> class while looking through header files, which led to a google search, then the better part of day reading documentation, and now confusion. So I figured I'd turn to the community. My questions concern the difference between auto_handle/stack semantics, and auto_gcroot/gcroot. auto_handle: My understanding is that this will clean up a

Entry point for C++/CLI x64 WindowsForms App (VS 2015)

独自空忆成欢 提交于 2019-11-29 17:04:24
I have the same problem as the user in Visual Studio 2015 c++/CLI boost::thread : If I use boost, Windows Forms and C++/Cli together, my app crashes on startup. The proposed solution works for me (change Subsystem to Console); the only small disadvantage is that the console is started alongside the GUI. There is another solution I've found (see https://bytes.com/topic/net/answers/642179-c-cli-winforms-app-native-static-library-singletons-cra ) : Changing the entry point to "?mainCRTStartupStrArray@@$$FYMHP$01AP$AAVString@System@@@Z". However this only works when compiling for 32 bit; for 64

Convert an IntPtr window handle to IWin32Window^

∥☆過路亽.° 提交于 2019-11-29 16:53:57
问题 How do I convert a handle acquired from a form/control's Handle property, to a IWin32Window^ ? 回答1: Control.FromHandle (That gets you the Control object, which implements the IWin32Window interface.) Eg. IntPtr myWindowHandle = IntPtr(someVal); IWin32Window^ w = Control::FromHandle(myWindowHandle); Note that this relies on the handle being "acquired from a form/control's Handle property." You cannot use this technique with an arbitrary Win32 window handle. 回答2: There's a simpler method that

c++/cli wrapper question

烈酒焚心 提交于 2019-11-29 16:15:20
Is there a recommended way to wrap a native c++ library by c++ cli? Hans Passant Not sure if one size fits all, but yeah, it is largely a mechanical process. Your ref class wrapper should declare a private member that's a pointer to your native C++ class. Create the instance in the constructor. You'll need a destructor and a finalizer to delete that instance again. Then for each function in the native C++ class you write a managed version of it. That's almost always a one-to-one call, you simply call the corresponding native method and let C++ Interop convert the arguments. Sometimes you have

C++/CLI: how to overload an operator to accept reference types?

自古美人都是妖i 提交于 2019-11-29 16:14:42
I am trying to create a CLI value class c_Location with overloaded operators, but I think I have an issue with boxing. I have implemented the operator overloading as seen in many manuals, so I'm sure this must be right. This is my code: value class c_Location { public: double x, y, z; c_Location (double i_x, double i_y, double i_z) : x(i_x), y(i_y), z(i_z) {} c_Location& operator+= (const c_Location& i_locValue) { x += i_locValue.x; y += i_locValue.y; z += i_locValue.z; return *this; } c_Location operator+ (const c_Location& i_locValue) { c_Location locValue(x, y, z); return locValue += i

Creating an C++/CLI OpenCV wrapper to use in C#

左心房为你撑大大i 提交于 2019-11-29 16:11:29
问题 I want to create an OpenCV wrapper to use it in C#. I am using this link as a reference http://drthitirat.wordpress.com/2013/06/06/use-opencv-c-codes-in-a-vc-project-solution-of-creating-a-managed-clr-wrapper/ So far I have created a C++ console application that contains my image processing code. Also I created a C++/CLI class library in which I wrapped the OpenCV code, but when i try to build it I get a lot of unresolved externals errors about OpenCV functions used in the C++ code and I don

System.Transactions.Diagnostics.DiagnosticTrace throwing TypeInitializationException

十年热恋 提交于 2019-11-29 15:42:18
Seems related to Strange exception coming out of OdbcConnection.Open() but I'm not sure. I recently switched over to Win8 and hadn't run this app since. I'm using VS2012, but the projects have not been upgraded. The dump of the exception looks like this: Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.TypeInitializationException: The type initializer for 'System.Uri' threw an

How to get full intellisense tooltip comments working?

自闭症网瘾萝莉.ら 提交于 2019-11-29 15:32:57
问题 I've got some C++/CLI software which is all nice and documented in a C#'ish kind of way which means DOxygen is able to pull it out into some nice html. Is there any way I can get that same information to appear in the intellisense tool tips the way that the .net framework does? For example, lets say this is my header file (MyApp.h): /*************** MyApp.h ***************/ /// My namespace containing all my funky classes namespace MyNamespace { using namespace System; ref class WorldHunger;

Is the sealed command c++ 0x or is it only microsoft who has it

此生再无相见时 提交于 2019-11-29 14:21:51
Is the sealed command going to be in c++ 0x or is it only MS who use it? C++0x has a special identifier final which means the same as sealed for classes in C++/CLI. It prevents a class from being derived from. Read about sealed in Wikipedia So the answer is basically: it already is but under a different name and has a different syntax. sealed is a really .net term and so is specific to MS C++/CLI. Sealed is used to declare a .net class that cannot be derived from. It's available in C++ but on for .net types in MC++. 来源: https://stackoverflow.com/questions/7026462/is-the-sealed-command-c-0x-or