managed-c++

Performance differences between P/Invoke and C++ Wrappers

无人久伴 提交于 2020-01-09 19:11:27
问题 In the process of learning P/Invoke, I asked this previous question: How to P/Invoke when pointers are involved However, I don't quite understand the implications of using P/Invoke in C# over creating a wrapper in Managed C++. Creating the same DLL using P/Invoke in C# definately resulted in a cleaner interface since I could use DLLImport on an embedded resource, but would a Managed C++ wrapper for a native DLL, where I do the marshaling myself, have better performance? 回答1: C++ wrapper

Performance differences between P/Invoke and C++ Wrappers

旧城冷巷雨未停 提交于 2020-01-09 19:10:11
问题 In the process of learning P/Invoke, I asked this previous question: How to P/Invoke when pointers are involved However, I don't quite understand the implications of using P/Invoke in C# over creating a wrapper in Managed C++. Creating the same DLL using P/Invoke in C# definately resulted in a cleaner interface since I could use DLLImport on an embedded resource, but would a Managed C++ wrapper for a native DLL, where I do the marshaling myself, have better performance? 回答1: C++ wrapper

convert from std::string to String^

给你一囗甜甜゛ 提交于 2020-01-09 05:40:09
问题 I have a function in C++ that have a value in std::string type and would like to convert it to String^. void(String ^outValue) { std::string str("Hello World"); outValue = str; } 回答1: Googling reveals marshal_as (untested): // marshal_as_test.cpp // compile with: /clr #include <stdlib.h> #include <string> #include <msclr\marshal_cppstd.h> using namespace System; using namespace msclr::interop; int main() { std::string message = "Test String to Marshal"; String^ result; result = marshal_as

csharp to java JNI porting call to run on ubuntu

强颜欢笑 提交于 2020-01-07 09:28:51
问题 I getting bug: crash happened outside the Java Virtual Machine in native code . whenever i run with class file with native library and .net module file it works fine. but when i try to run alone class file and native library it gets crash .please clarify my mistake i have done, please review my code. for your reference with parameter ========================================== public class Sum { public int add(int a, int b) { return a + b; } } =========================================== save

C++: Getting the “error C2065: 'pst' : undeclared identifier” while using pstsdk?

假装没事ソ 提交于 2020-01-07 04:08:12
问题 Following the suggestion of working with the pstsdk in this question: Processing Microsoft Office Outlook 2003/2007 email messages… And following the instructions here: PST File Format SDK - PST Layer Overview - Getting Started And also according to this video: In PST SDK Presentation, Terry Mahaffey, discusses the PST SDK file format SDK. (Forward it to 28:32) They all agree that I only have to include the PST header file after having properly added the include paths for both Boost and

Events in Managed C++: Problem with Events, WindowEvents

别等时光非礼了梦想. 提交于 2020-01-06 04:32:28
问题 Working on a VisStudio 2008 addin, using managed C++ (C++/CLR in the New Project wizard). In the OnConnection() function, I want to add a handler to the WindowEvents collection. When I do this: // Hook up events EnvDTE::Events ^ events = _applicationObject->Events; EnvDTE::WindowEvents ^winEvents = events->WindowEvents(); I get an error message: error C2660: 'EnvDTE::Events::WindowEvents::get' : function does not take 0 arguments In the Object Browser I find this: public EnvDTE.WindowEvents

Necessary to pin_ptr on C++ CLR Value types, why?

╄→尐↘猪︶ㄣ 提交于 2020-01-04 19:02:34
问题 Since .NET Value types (managed C++ structs) are stored on the Stack why is it (or, alternatively is it actually) necessary to pin_ptr them in order to pass a pointer to an unmanaged function? Eg. BYTE b[100]; If I pass &b to an unmanaged function without first pinning it, may the stack become corrupted? Is the CLR stack subject to change in the same way as the GC Heap? I am led to believe that the CLR Stack uses unusual optimizations such as using processor registers which makes it

Necessary to pin_ptr on C++ CLR Value types, why?

我怕爱的太早我们不能终老 提交于 2020-01-04 19:02:18
问题 Since .NET Value types (managed C++ structs) are stored on the Stack why is it (or, alternatively is it actually) necessary to pin_ptr them in order to pass a pointer to an unmanaged function? Eg. BYTE b[100]; If I pass &b to an unmanaged function without first pinning it, may the stack become corrupted? Is the CLR stack subject to change in the same way as the GC Heap? I am led to believe that the CLR Stack uses unusual optimizations such as using processor registers which makes it

Necessary to pin_ptr on C++ CLR Value types, why?

我的梦境 提交于 2020-01-04 19:02:08
问题 Since .NET Value types (managed C++ structs) are stored on the Stack why is it (or, alternatively is it actually) necessary to pin_ptr them in order to pass a pointer to an unmanaged function? Eg. BYTE b[100]; If I pass &b to an unmanaged function without first pinning it, may the stack become corrupted? Is the CLR stack subject to change in the same way as the GC Heap? I am led to believe that the CLR Stack uses unusual optimizations such as using processor registers which makes it

How do you dispose of an IDisposable in Managed C++

我的梦境 提交于 2019-12-30 07:54:07
问题 I'm trying to Dispose of an IDisposable object(FileStream^ fs) in managed C++ (.Net 2.0) and am getting the error 'Dispose' : is not a member of 'System::IO::FileStream' It says that I should invoke the destructor instead. Will calling fs->~FileStream(); call the dispose method on the FileStream object? Why can't I call Dispose? 回答1: The correct pattern is to just delete the object: delete fs; This will be translated into a call to Dispose() See this post for some of the details of what is