c++-cli

Debugger does not step into native code when debugging a static lib wrapped in a C++/CLI DLL

百般思念 提交于 2020-02-25 00:51:07
问题 In a C# app, I'm referencing a native C static lib, that I wrapped in a C++/CLI DLL. I chose a static lib versus a DLL because I have other constraints related to the release process of the app to the user. Among the many topics available on this forum I found the following implementation. Main : { MyCLRDLL test = new MyCLRDLL(); if(test.go()) Console.WriteLine("Hello, wrld"); } In the DLL project, the file MyCLRDLL.hpp #include "MyNativeLib.h" #pragma comment(lib, "MyNativeLib.lib")

expose c++/CLI templated wrapper to c#

不问归期 提交于 2020-02-23 04:00:27
问题 I am currently working on a visual editor to build Finite State Machines. The core is c++ since the built FSM will run in a game. The editor is c#. I was able to get a CLI wrapper going so I can build everything I need in the c# side. The last thing I am trying to do, is to be able to expose a templated class to c#. I started by creating a managed class: template <typename T> public ref class TestTemp { private: ClassToWrap<T>* m_val; public: TestTemp(T val) : { m_val = new ClassToWrap<T>();

expose c++/CLI templated wrapper to c#

你离开我真会死。 提交于 2020-02-23 04:00:07
问题 I am currently working on a visual editor to build Finite State Machines. The core is c++ since the built FSM will run in a game. The editor is c#. I was able to get a CLI wrapper going so I can build everything I need in the c# side. The last thing I am trying to do, is to be able to expose a templated class to c#. I started by creating a managed class: template <typename T> public ref class TestTemp { private: ClassToWrap<T>* m_val; public: TestTemp(T val) : { m_val = new ClassToWrap<T>();

Dispatching events into right thread

六月ゝ 毕业季﹏ 提交于 2020-02-07 07:48:49
问题 I have developed a wrapper for a library that uses a callback to notify events. This callback is called using another thread than UI's thread, so the wrapper uses the following script to call the event handlers into the right thread for a WinForm application. void AoComm::Utiles::Managed::DispatchEvent( Delegate^ ev, Object^ sender, Object^ args ) { ComponentModel::ISynchronizeInvoke^ si; array<Delegate^>^ handlers; if(ev != nullptr) { handlers= ev->GetInvocationList(); for(int i = 0; i <

Restrict Text Box to only accept 10 digit number

北战南征 提交于 2020-02-04 05:23:06
问题 I have a Text Box that is a System::String^ , I need to confirm that this only accepts 10 digits numbers and no letters, symbols, etc. How would I implement this in C++ visual studio? Do I need to convert the contents to a std::string first? 回答1: Assuming this is a .NET winforms text box (since your snippet is C++/CLI), you want to set the "MaxLength" property. (Something like TextBox^ tb = gcnew TextBox(); tb->MaxLength = 10 .) For the numbers-only part, you want to assign a delegate to the

Visual C++ CLR designer is always showing 0x8000000A error in the second run of the project and editing design

旧城冷巷雨未停 提交于 2020-01-26 03:39:05
问题 I'm trying to make a great GUI for my csgo cheat. I decided to use C++/CLR. Firstly I create empty project then, I change in a properties entrypoint and the subsystem and I add this code to the cpp file: #include "MyForm.h" using namespace System;` using namespace System::Windows::Forms;` [STAThreadAttribute] void Main(array<System::String ^> ^args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); SmallPackofCheats::MyForm mainForm; Application::Run(

Passing a tracking handle as a void*

こ雲淡風輕ζ 提交于 2020-01-25 03:43:06
问题 I'm interfacing the statistical language R direcly from .NET using managed c++. I'm a little green in Managed C++, and I need to do something a little tricky. A structure use to pass to a function has a generic data pointer void* used to pass some payload data usable in a later callback. Hope I explained, is a pretty well used pattern in C/C++. But for my use I need to pass a managed object by using that void * , how can I do? I'm trying with: BinaryWriter^ bs=gcnew......; stream->data=(void*

Changing foreach iteration variable and implementation differences between C# and C++/CLI

馋奶兔 提交于 2020-01-24 20:26:06
问题 Consider the following C# code. string[] stringArray = new string[10]; foreach (string s in stringArray) s = "a new string"; // Compiler error - Can't assign to foreach iteration variable Now consider the following valid C++/CLI code. array<String^>^ stringArray = gcnew array<String^>(10); for each(String^% s in stringArray) s = "a new string"; When foreach is used with array type, compiler translates it into normal for loop. This implementation is same for C# and C++/CLI. So I wonder if C++

Visual Studio 2015 c++/CLI boost::thread [duplicate]

眉间皱痕 提交于 2020-01-23 12:28:24
问题 This question already has an answer here : How do I create a C++/CLI Winforms app in VS2012? (1 answer) Closed 3 years ago . This issue has been around for all Visual Studio versions, but in VS 2015 the "old tricks" don't seem to work anymore. This is what I have tried: create a Windows Forms application in VS 2013 and 2015 (the macro is missing since VS 2013, so see this post: Can't find Windows Forms Application for C++) add boost headers path to Additional Include Directories add #include

C++/CLI: preventing garbage collection on managed wrapper of unmanaged resource

只谈情不闲聊 提交于 2020-01-21 06:29:05
问题 I have a C++ unmanaged class NativeDog that needs to be used from C#, so I've create a wrapper class ManagedDog . // unmanaged C++ class class NativeDog { NativeDog(...); // constructor ~NativeDog(); // destructor ... } // C++/CLI wrapper class ref class ManagedDog { NativeDog* innerObject; // unmanaged, but private, won't be seen from C# ManagedDog(...) { innerObject = new NativeDog(...); ... } ~ManagedDog() // destructor (like Dispose() in C#) { // free unmanaged resources if (innerObject)