c++-cli

exception HRESULT: 0x800700C1 when executing c# application referencing native c++ lib with boost

↘锁芯ラ 提交于 2019-12-06 18:45:14
问题 I am running a C# application that references a C++\CLI wrapper project which in turn references a native c++ project dependent on Boost 1.47 library (links to files of the form ...vc100-mt-gd-1_47.lib) All libraries are statically linked and everything compiles great. Executing the C# app results in an exception: "...is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)." claiming some dependency is missing somewhere. C# application is configured to x86 platform while all

Convert System::object to string array

僤鯓⒐⒋嵵緔 提交于 2019-12-06 16:41:36
I need to return four dimensional array of strings during the work of background worker which is receiving data via serial port. In background worker: array<String^>^ Received = gcnew array<String^>(4); backgroundWorker1->ReportProgress(10,Received); In report progress: private: System::Void backgroundWorker1_ProgressChanged(System::Object^ sender, System::ComponentModel::ProgressChangedEventArgs^ e) { array<String^>^ Received2 = gcnew array<String^>(4); Received2 =(e->UserState); } I am getting: error C2440: '=' : cannot convert from 'System::Object ^' to 'cli::array " which is not a surprise

expose c++/CLI templated wrapper to c#

≡放荡痞女 提交于 2019-12-06 16:27:54
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>(); } } Then since templates are generated at compile time, I am forcing the generation of the type with

VS 2012 Debugger, modules loaded twice, breakpoint couldn't be hit

守給你的承諾、 提交于 2019-12-06 13:40:10
I have a Visual Studio 2012 solution which contains two projects, 1st is C++/CLI wrapper and the 2nd is C# , where I use the wrapped dll. Both projects are in 32 bit debug mode. In C# project Enable native code debugging option is enabled. In C++/CLI debugging mode is set to mixed . The problem is that in both projects the breakpoints can't be hit. I followed advices from here and here but without luck. The most interesting thing, that bot projects are loaded twice, the locations are the same and symbols files are loaded from the same directory, there exe and dll are placed. It's also

Write logs in Visual Studio 2008

别等时光非礼了梦想. 提交于 2019-12-06 13:22:08
I am writing application on C++ .NET in Visual Studio 2008. I want to ask if there is standard function for writing logs ? Edited it mean I can write such code and where I can see output logs ? #ifdef DEBUG Trace::Write("Message", "Category"); #endif Teoman Soygul Trace::Write("Message", "Category"); Debug::Write("Message", "Category"); // Same thing as #ifdef DEBUG Trace::Write(...) is pretty much the prebuilt logging facility. To get the output to a file, append the below configuration to your app.config file, all the output will be written to c:\myListener.log : <configuration> <system

Mixed types are not supported

送分小仙女□ 提交于 2019-12-06 13:16:01
Please have a look at the following header file #pragma once using namespace UsbLibrary; ref class MissileLauncher { public: MissileLauncher(void); private: //Bytes used in command unsigned char UP[10]; unsigned char RIGHT[10]; unsigned char LEFT[10]; unsigned char DOWN[10]; unsigned char FIRE[10]; unsigned char STOP[10]; unsigned char LED_OFF[9]; unsigned char LED_ON[9]; UsbHidPort USB; }; I am using a Visual C++ project (C++/CLI ?) in visual studio professional 2010. When I run this code, I get lot of errors Error 1 error C4368: cannot define 'UP' as a member of managed 'MissileLauncher':

Calling C# code from visual C++

牧云@^-^@ 提交于 2019-12-06 12:57:32
Basically I need to call C# code from Visual C++ code. After reading lots of articles about possible ways, I decided I want to use C++/CLI mechanism. Initially I decided I will have some functions in C++ native code (dll library project), they will call some functions from a CLR project which will call some functions from a C# project. After that I thought that maybe I could get rid of the bridge project (the CLR project) since it only makes the transition to managed world. I think that I can just create my native project, and I can add a c++ source file to it and I can enable CLR support just

Connecting c++ and c# code with a c++/cli bridge

北城以北 提交于 2019-12-06 12:31:15
问题 I have a client application in native c++ code which is using native c++ dlls. I am investigating the possibility of connecting this code with c# dlls as they would be much easier to write. I decided to write a c++/cli bridge dll which can be loaded with LoadLibrary and which would pass the calls to c# dll. The communication between the client and the dll is such that the client passes a pointer to an interface object through which the dll then communicates with the client. I wrapped this

Marshalling C# structure to C++ Using StructureToPtr

浪子不回头ぞ 提交于 2019-12-06 12:18:24
I have C# class: namespace Models { [StructLayout(LayoutKind.Explicit, Size = 120, CharSet = CharSet.Unicode)] public struct DynamicState { [FieldOffset(0)] public double[] Position; [FieldOffset(24)] public double[] Velocity; [FieldOffset(48)] public double[] Acceleration; [FieldOffset(72)] public double[] Attitude; [FieldOffset(96)] public double[] AngularVelocity; } } and C++/CLI method: Models::DynamicState SomeClassClr::DoSomething(Models::DynamicState ds) { int struct_size = Marshal::SizeOf(ds); System::IntPtr ptr = Marshal::AllocHGlobal(struct_size); DynamicStateStruct ds_struct; struct

Did I read somewhere that C++/CLI moves us towards a “header-file” less society, like Java

有些话、适合烂在心里 提交于 2019-12-06 12:07:22
问题 And if so, should I be trying to keep header file use to a minimum when creating classes? 回答1: (This may come 3 years late, but it still shows up near the top on a google search, and the information is still valid today as it was 3 years ago). First, yes you are correct, with C++/CLI you don't use .h files EXCEPT for native C++ classes, structures, etc. The first question that may come to mind is how do I reference my class if I don't #include "someheader.h" file? There are two answers to