c++-cli

passing a HANDLE variable to an unmanaged .dll in C++/CLI

烈酒焚心 提交于 2019-12-08 04:57:26
问题 I am trying to wrap an unmanaged c++ dll that talks to a video capture card in c++/CLI so i can reference the functions from a c# project that i have. I am having trouble getting the 1st wrapped call to work as I am new to c++/cli syntax. here is what i have. here is the function declataion i am trying to wrap. __declspec(dllimport) BOOL AZ_DeviceCreate(HANDLE& hLiveEvent, DWORD* hEncoderEvent, DWORD* pdwEncoderAddress, HANDLE& hAudioEvent, DWORD& dwAudioAddress); here is my c++/cli .h file

Intermittent Access Violation ID2D1RenderTarget::EndDraw

此生再无相见时 提交于 2019-12-08 04:46:18
问题 I have my Direct2D drawing loop which is running successfully for hours, even days, except for the intermittent access violation error. There is no pattern for this to happen, mostly after several hours, sometimes after just a few seconds. Unhandled exception at 0x5f990099 (d3d11.dll) in XX.exe: 0xC0000005: Access violation reading location 0x00000fe0. I am keeping a log of the return HRESULT of EndDraw if not successful. All the previous EndDraw s seem to return S_OK . There aren't any other

Passing pointer from managed C++/CLI to ActiveX C++ component

岁酱吖の 提交于 2019-12-08 04:31:56
问题 I have an ActiveX component built in C++. One of its methods has this signature: short Component::Method(short FAR* ptr) {} When the I add the ActiveX into my C++/CLI application the method signature shows as: short Compnenet::Method(short% ptr) {} I want to be able to correctly pass short* pSomething; variable value to this method. of course, the new signature doesn't accept passing arguments as short* and even if you try to cast to short% it doesn't give right results. Note: I don't have

How to use c/c++ struct in C# code?

白昼怎懂夜的黑 提交于 2019-12-08 04:23:41
问题 I'm using some service that send me byte array using UDP. This service application was developed in C - and this this byte array is a C struct. I know that i can redefine this struct on C# and using the StructLayout attribute to have the same alignment of a member ( am i right ? ) But is it possible to define the same struct using managed C++/CLI and import this managed C++ code to my C# project and on this way to do the serialization ? If this is possible - so how to do it ? I can't find any

VS2008 XAML design view chokes on namespaced C++ assembly

拟墨画扇 提交于 2019-12-08 04:15:58
问题 I have a C++ assembly with both managed and umanaged code compiled to a DLL. It is correctly imported into the project references as I can see all my classes and their members with the Object Browser. The problem is with the XAML Design view. In my XAML code I want to make a data bind with my C++ assembly so I have the namespace like so: xmlns:kudu="clr-namespace:kudu;assembly=CLI" CLI is the name of the dll and it has a namespace inside called kudu. The Design view refuses to shows the XAML

C++\Cli Parallel::For with thread local variable - Error: too many arguments

扶醉桌前 提交于 2019-12-08 04:02:34
问题 Trying to implement my first Parallel::For loop with a tread local variable to sum results of the loop. My code is based on an example listed in "Visual C++ 2010, by W. Saumweber, D. Louis (German). Ch. 33, P.804). I get stuck in the implementation with syntax errors in the Parallel::For call. The errors are as follows, from left to right: a) expected a type specifier, b) too many arguments for generic class " System::Func ", c) pointer to member is not valid for a managed class, d) no

Accessing embedded resources in C++/CLI

霸气de小男生 提交于 2019-12-08 03:45:16
问题 I've been working with C# for a while, and I'm trying to write a .NET app in C++ this time. In C# I was able to access the managed resources from the code quite easily, the name of the resource file worked sort of like a class, so if I had a string called "abc" in a resource file called cba.resx, simply writing cba.abc returned with the string from the resource file. Even intellisense works with it. Same thing works with icons, etc. Is it possible to do the same in C++, and if so, how? Or if

Mixed types are not supported

♀尐吖头ヾ 提交于 2019-12-08 03:43:57
问题 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

C++/CLI: Is overloading on return type only possible?

最后都变了- 提交于 2019-12-08 03:16:56
问题 If I understand well, in C#, it is possible to do public class X : ICloneable { public X Clone() { ... } object ICloneable.Clone() { return Clone(); } // This calls the above } according to this thread. This kind of overloading is forbidden in C++, since it only depends on the return type. Now, I would like to do this exact thing with ICloneable in C++/CLI. Is there a way ? 回答1: This type of overloading is allowed in C# not because of different return type, but because of explicit

Convert System::object to string array

寵の児 提交于 2019-12-08 03:15:24
问题 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