mixed-mode

C++/cli to c++: Error s incompatible with “void (__stdcall *)(int i, std::string str)”

妖精的绣舞 提交于 2019-12-25 17:03:40
问题 I am new to C++/cli so please excuse me for silly questions or core mistakes: My C++/CLI class Library that is called by C# has only one method: ThreadsCppWrapper.h namespace namespace ThreadsCppWrapper { public ref class ThreadsCppWrapperClass { public: ThreadsCppWrapperClass(); // Constructor System::String^ mytrainOp(System::MulticastDelegate^ callbackfunction); private: MyThreadsCpp::MyThreadsCppClass* ptr; }; } ThreadsCppWrapper.cpp System::String^ ThreadsCppWrapper:

Unload mixed mode assembly

半城伤御伤魂 提交于 2019-12-25 04:11:51
问题 I have native windows application developed mainly in C++. I would like to put some C# / UI components on top of that application. But main application is rather heavy to start up and debug, I would like for C# to be polite to application and it would be possible to develop UI without closing native application for as long as possible. In C++ there is always LoadLibrary and FreeLibrary - so developer can release .dll during development of his component, in C# once you load your assembly it's

Can managed and unmanaged C++/MFC be mixed in one dll?

风格不统一 提交于 2019-12-24 02:18:05
问题 Previously we had software in MFC (VC6), VB6 and C# applications that needed to call the same engine written in C++ (and MFC). The engine required C++ for speed. At the time we decided to use COM as the interface because all three could use it with the least issues in marshalling, etc. Our MFC application is now deprecated and we have recently decided to dump VB6, so what we've got left is C#. We can just leave the COM engine as-is, but it would be nice to get away from COM registration, etc.

C++/CLI: inherit from one CLR class, multiple C++ classes

偶尔善良 提交于 2019-12-23 16:26:53
问题 In C++/CLI, I want a class hierarchy similar to the following: Foo FooA : Foo, ClrClassA FooB : Foo, ClrClassB Is it possible for FooA to share a (non CLR) base class while also inheriting from separate CLR classes? If not, what would be the best way for FooA and FooB to share common code? 回答1: Generally speaking, composition is often better than inheritance as it tends to lead to less tightly coupled designs. If you're mixing managed and unmanaged code, it's generally easier in my experience

C++\CLI - How to convert UInt64^% to unsigned long long*

↘锁芯ラ 提交于 2019-12-23 13:27:34
问题 I have a C++ function that calculates a buffer size: CalcBuffer(unsigned long long* bufferSize); I want to pass this result into a different function later in my C# code. My C++\CLI Wrapper looks like this: CalcBufferWrapper([Out] UInt64^% bufferSize){ CalcBuffer(bufferSize); } But I'm getting this error: argument of type "System::UInt64 ^" is incompatible with parameter of type "unsigned long long *". Obviously, I need to use a different type, but which type? 回答1: UInt64^% doesn't mean what

Fast capture stack trace on windows / 64-bit / mixed mode

落花浮王杯 提交于 2019-12-18 13:28:10
问题 Like most of you probably know there exists plenty of different mechanisms to walk stack traces, starting from windows api, and continuing further into depth of magical assembly world - let me list here some of links I've already studied. For of all let me mention that I want to have mechanism of memory leak analysis of mixed mode (managed and unmanaged) / 64-bit + AnyCPU application and from all windows api's CaptureStackBackTrace is most suitable for my needs, but as I have analyzed - it

How can I send a managed object to native function to use it?

馋奶兔 提交于 2019-12-18 04:23:34
问题 How can I send a managed object to native function to use it? void managed_function() { Object^ obj = gcnew Object(); void* ptr = obj ??? // How to convert Managed object to void*? unmanaged_function(ptr); } // The parameter type should be void* and I can not change the type. // This function is native but it uses managed object. Because type of ptr could not be // Object^ I called it "Unmanaged Function". void unmanaged_function(void* ptr) { Object^ obj = ptr ??? // How to convert void* to

Standard conformant way of converting std::time_t to System::DateTime?

痞子三分冷 提交于 2019-12-17 19:29:04
问题 I have already found several answers related to converting a std::time_t value to System::DateTime and back. However, almost all answers seem to neglect that the type of std::time_t is actually undefined in the standard. Most solutions just cast std::time_t to whatever needed or apply arithmetic operations to a std::time_t object which is possible since it's an arithmetic type, but there is no specification about the result of such an operation. I know that most compilers define time_t as an

Visual Studio: Garbled debug watch of std::string's?

陌路散爱 提交于 2019-12-13 14:08:04
问题 When I'm debugging C++ mixed (managed/unmanaged) projects in Visual Studio 2005, I often get weird data from the debug watches, like below : (btw, the variable i_processName is a const std::string & ) alt text http://img175.imageshack.us/img175/3561/43419953av1.jpg Note that the variable actually holds valid data - if i print it to stdout, the printed string is just fine, thanks for asking. The simpler types of data (e.g. int s) (usually?) get their correct values shown. Did this ever happen

Create a mixed mode C++/CLI DLL

大城市里の小女人 提交于 2019-12-13 06:27:27
问题 I hope not to repeat something already asked..I search around but I haven't found something similar. I have developed a native sdk which expose some classes and interfaces. Now, I need to implement a mixed mode DLL which uses this SDK. But the following code does not compile: WrapperClass.h #pragma once #include <vcclr.h> #using <mscorlib.dll> class WrapperClass{ public: WrapperClass(); private: gcroot<Client^> m_ManagedObj; }; NativeClass.h #pragma once #include "stdafx.h" #include