c++-cli

How can I insert C code into C++/CLI code?

六月ゝ 毕业季﹏ 提交于 2019-12-12 06:57:07
问题 I have some files written in C that I want to insert into my .NET C++/CLI code. This C code is huge and has not been written by me, so it would be a hard task to me 'translating' all the code. How can I insert this code and call the functions I need without any compatibility problems? I used to think that, if C++/CLI is definitely C++ and C is compatible with C++, there is no problem to insert C code into C++/CLI code. But I've read about something called extern "C" , which made me change my

show vector elements in listbox

戏子无情 提交于 2019-12-12 06:28:24
问题 I would like to display the elements in a vector in a listbox. However, I'm constantly getting a error: error C2664: 'System::Windows::Forms::ListBox::ObjectCollection::Add' : cannot convert parameter 1 from 'std::basic_string<_Elem,_Traits,_Alloc>' to 'System::Object ^' I am using windows form in c++/cli. this is the code: for (size_t z = 0; z < container.size(); z++){ listBox_name->Items->Add(container[z]); } 回答1: Based on the error message, your vector is a vector of std::string . Use

intellisense not shown on public classes, but on private ones

≡放荡痞女 提交于 2019-12-12 04:57:15
问题 I am currently trying out writing my own Intellisense comments into my sources as described in stackoverflow 8240402 stackoverflow 1632942 but it's not yet working correctly. I'm using VS 2008. I have a assembly "testAssembly" (compiled to a DLL) with ref class class1a and public ref class class1b : namespace testAssembly { /// <summary> /// Testkommentar class1a /// </summary> ref class class1a { int m_iValue; public: /// <summary> /// Testkommentar class1a constructor /// </summary> class1a

Why C# change my color structure to ValueType?

做~自己de王妃 提交于 2019-12-12 03:58:02
问题 I have defined following code in C++ CLI. However when I want to call SetColor the first parameter which is supposed to appear as System.Drawing.Color; appears as ValueType. This also let me to pass any variable into it. No matter if it's Color or not. [System::Runtime::CompilerServices::ExtensionAttribute] public ref class MyExtensions abstract sealed { public: [System::Runtime::CompilerServices::ExtensionAttribute] static System::String^ SetColor(System::String^ in, System::Drawing::Color^

How to move/copy data from MFC to C++/CLI using events/delegates/callback

岁酱吖の 提交于 2019-12-12 03:49:58
问题 We have a MFC application setup where a client receives data from server whenever new data is available. Client is being rewritten in C# but communication with server part is in MFC. We have written a C++/CLI wrapper to classes associated with MFC and are able to receive data on application initialization. Communication engine is still in MFC and we have created wrapper classes only for data items. When we initialize the CLI wrapper we copy the data from MFC arrays to CLI arrays. But am not

Convert Object to Array C++/CLi

会有一股神秘感。 提交于 2019-12-12 03:48:54
问题 I am using VS2010, windows forms application(C++) array<int>^ MyArray = gcnew array<int>(10){1,2,3,4,5,6,7,8,9,10}; Object^ MyObj = MyArray; But when I try to get MyObj->Length I get error. U may ask why do I need an object? The answer is, the main goal is to create a Dictionary Put any type value in it and be able to get access to read, edit etc. Dictionary<String^, Object^>^ MyDic = gcnew Dictionary<String^, Object^>; array<int>^ MyArray = gcnew array<int>(10){1,2,3,4,5,6,7,8,9,10}; MyDic[

Different dependency resolution behavior loading assembly in default AppDomain vs new AppDomain

岁酱吖の 提交于 2019-12-12 03:38:53
问题 I've been looking at an issue related to unit testing and managed/native interop via C++/CLI. The details aren't important so I won't fill them in unless asked, but the situation can be distilled as follows: Two assemblies, call them Lib and Dep, exist in the same directory, call it D. Lib depends on Dep via an assembly reference. We are running in an application that lives in a different, unrelated directory. The application creates a new AppDomain with ApplicationBase set to directory D,

c++/clr StructureToPtr Stack buffer overflow

给你一囗甜甜゛ 提交于 2019-12-12 03:25:48
问题 as I have asked in this question c++/clr StructureToPtr exit application without any exception or error and thanks to the comment, I found out the exit code is -1073740791 , which means Stack buffer overflow / overrun. So let me post my two structures, [StructLayout(LayoutKind::Sequential)] public ref struct ThostFtdcInputOrderField { [MarshalAs(UnmanagedType::ByValTStr, SizeConst = 11)] String^ BrokerID; [MarshalAs(UnmanagedType::ByValTStr, SizeConst = 13)] String^ InvestorID; [MarshalAs

CLI/C++. How does it differ to 'normal' c++ or visual c#?

三世轮回 提交于 2019-12-12 02:50:07
问题 I was programming some not ambitious, small programs in my school in Dev C++ for ages now in school. But now it came out i need to make a window application. I saw some people using visual studio for that. Few days ago i got Visual Studio C++ express, and i after a while of coding, after few lines i realized it differs much from "normal" C++ i was using so far. Even declarations of strings are giving me headache. I wanted to ask, if maybe visual c# would be more similar to what i know, or

c++ byte array to bitmapimage

亡梦爱人 提交于 2019-12-12 02:46:29
问题 This is my first question on stackoverflow. I'm new to UWP programming, and due to some reason I need to do it in C++. Now I'm trying to solve this problem: I've got a byte array of images and want to show them in the UI. The following code is what I've tried but seems don't work. Here is C++ code: BYTE input[160000] = ...; InMemoryRandomAccessStream ^stream = ref new InMemoryRandomAccessStream(); DataWriter ^writer = ref new DataWriter(); writer->WriteBytes(Platform::ArrayReference<BYTE>