c++-cli

Pass a function pointer from C++ to be called by C# - Arguments of functions include a wide char string (LPCWSTR)

和自甴很熟 提交于 2019-12-18 06:58:02
问题 I am writing a C# library to be used by native C++ application. I am using C++/CLI as the Interoperability mechanisim. I require to pass a callback function from C++ to C# (using C++/CLI as the intermediate layer). C# library needs to call the C++ function with a zero terminated string of wide characters; i.e. the prototype of the callback function is Func(LPCWSTR pszString); There are other parameters but they are immaterial for this discussion. I searched net and found Marshal

C++/CLI String Conversions

女生的网名这么多〃 提交于 2019-12-18 05:18:51
问题 I found this really nice piece of code that converts a string to a System:String^ as in: System::String^ rtn = gcnew String(move.c_str()); // 'move' here is the string I'm passing rtn back to a C# program. Anyways, inside the function where this code exists, I'm passing in a System::String^ . I also found some code to convert a System:String^ to a string using the following code: pin_ptr<const wchar_t> wch = PtrToStringChars(cmd); // 'cmd' here is the System:String size_t convertedChars = 0;

Writing data to disk in parallel?

浪尽此生 提交于 2019-12-18 05:17:34
问题 So I am working on a C++/cli image processing library and am trying to optimize my code. Basically, I am passed a System::Drawing::Bitmap of the image, which I then need to write to disk, perform complex analysis on, and return the results of the analysis. I thought that I could write the image to disk in parallel to speed up things (my algorithm does not modify the image). However, I have not worked with threads much, so I wanted to get your input on what the best way to do this would be.

c++/cli caret^ Vs. Pointer*?

冷暖自知 提交于 2019-12-18 04:42:14
问题 I've programming for a long time in C and in C#, I thought moving to C++ would be smooth... anyway, I've seen the use of caret but I don't understand the meaning of it. what's the different between: std::string *st1; to String::string ^st2; Thanks! 回答1: The caret is specific to C++/CLI, Microsoft's .NET version of C++, where it is the managed equivalent of a pointer. It is not actually part of standard C++, so unless you truly mean to use .NET, don't use it. 回答2: String::string ^st2 is not a

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

AnyCPU/x86/x64 for C# application and it's C++/CLI dependency

拟墨画扇 提交于 2019-12-18 02:18:30
问题 I'm Windows developer, I'm using Microsoft visual studio 2008 SP1. My developer machine is 64 bit. The software I'm currently working on is managed .exe written in C#. Unfortunately, I was unable to solve the whole problem solely in C#. That's why I also developed a small managed DLL in C++/CLI. Both projects are in the same solution. My C# .exe build target is "Any CPU". When my C++ DLL build target is "x86", the DLL is not loaded. As far as I understood when I googled, the reason is C++/CLI

AnyCPU/x86/x64 for C# application and it's C++/CLI dependency

最后都变了- 提交于 2019-12-18 02:17:31
问题 I'm Windows developer, I'm using Microsoft visual studio 2008 SP1. My developer machine is 64 bit. The software I'm currently working on is managed .exe written in C#. Unfortunately, I was unable to solve the whole problem solely in C#. That's why I also developed a small managed DLL in C++/CLI. Both projects are in the same solution. My C# .exe build target is "Any CPU". When my C++ DLL build target is "x86", the DLL is not loaded. As far as I understood when I googled, the reason is C++/CLI

Managed C++ to form a bridge between c# and C++

不打扰是莪最后的温柔 提交于 2019-12-17 22:34:41
问题 I'm a bit rusty, actually really rusty with my C++. Haven't touched it since Freshman year of college so it's been a while. Anyway, I'm doing the reverse of what most people do. Calling C# code from C++. I've done some research online and it seems like I need to create some managed C++ to form a bridge. Use __declspec(dllexport) and then create a dll from that and use the whole thing as a wrapper. But my problem is - I'm really having a hard time finding examples. I found some basic stuff

Does the ^ symbol replace C#'s “ref” in parameter passing in C++/CLI code?

只愿长相守 提交于 2019-12-17 22:25:10
问题 In C#, passing by reference is: void MyFunction(ref Dog dog) But in C++/CLI code examples I have seen so far, there is no use of ref but instead ^ symbol is used: void MyFunction(Dog ^ dog) Is the use of ^ symbol a direct replacement for ref when parameter passing? or does it have some other meaning I'm not aware of? Additional Question: I also see a lot of: Dog ^ myDog = gcnew Dog(); It looks like it's used like * (pointer) in C++.. Does it work similarly? Thanks! 回答1: If Dog is a reference

Windows Azure not finding DLL of C++/CLI project

*爱你&永不变心* 提交于 2019-12-17 19:54:17
问题 I have a C++/CLI project that wraps around an unmanaged C compression library, and this project is referenced by an MVC3 project that calls the C++ Compress function. Everything works fine locally, but when I publish the solution to the Azure cloud, I get an error saying it could not find the module/dll: Could not load file or assembly 'LZGEncoder.DLL' or one of its dependencies. The specified module could not be found. Why can't it find the DLL file? is it going to the wrong place or being