c++-cli

Looking for a faster-than-GDI solution for rendering dynamic data plots

这一生的挚爱 提交于 2019-12-04 17:45:55
I've written a simple GDI-based data plotter using C++/CLI but it's not particularly fast (some basic profiling indicates it's the rendering to screen that's the problem). Is there any way to enable hardware acceleration for a UserControl or is there a .net interface for direct3D? ...or are there some other options I could consider. We're using managed code so the solution really needs to be CLI compatible if at all possible. [Edit] In case it helps, I'm rending strips (128 data points) of rectangles which are each 2x2 pixels using Graphics::FillRectangle - maybe there's a better way of doing

Unreachable breakpoint at execut(able/ing) code

醉酒当歌 提交于 2019-12-04 17:01:20
I've got two DLLs, one in written in native C++ and the other in C++/CLI. The former is injected into a process, and at a later point in time, loads the latter. While debugging, I noticed that the native DLL's breakpoints were functioning correctly while the other's weren't, even though its code was being executed. The breakpoints showed this message: This breakpoint will not be hit. No executable code associated with this line. Possible causes include: preprocessor directives or compiler/linker optimizations. The modules window tells me that the plugin's symbols are loaded. I'm running with

How to wrap C library callbacks in C++/CLI

北慕城南 提交于 2019-12-04 16:39:11
Given the following C library with a callback event that ask to set a buffer, how to write a proper C++/CLI wrapper in a type safe manner? // The callback signature typedef void (__cdecl *BUFFERALLOCATOR)(void *opaque, void **buffer); // A struct that contains the context of the library struct lib_context_base_s { // The stored callback function pointer BUFFERALLOCATOR buffer_allocator; // Opaque pointer that contain the local context. Needed in C because // C doesn't have closures (functions that knows the context where // they are defined) void* opaque; }; typedef struct lib_context_base_s

How to use a separate .cpp file for my event function definitions in windows forms?

烈酒焚心 提交于 2019-12-04 16:24:10
I'm having trouble defining my C++ event functions in windows forms. I want to define my event functions (example: button click) in a separate .cpp file instead of doing all the function definitions in the windows forms .h file that's already full of generated code for the windows forms GUI. I tried doing this, Declaration inside the Form1.h class: private: System::Void ganttBar1_Paint (System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e); And this is the definition inside Form1.cpp class: #include "Form1.h" System::Void Form1::ganttBar1_Paint(System::Object^ sender, System:

C++/cli -> calling c# dll -> calling OpenFileDialog issue

◇◆丶佛笑我妖孽 提交于 2019-12-04 16:12:34
I write extensions to a C++ program. I write standard C/C++ dlls and I use IJW to call C# dlls. This has always worked perfectly until I wrote and called a C# dll that in turn called an OpenFileDialog and a SaveFileDialog. Whenever either was called with ShowDialog, the app would freeze. So in making a "Minimum Working Example" I got an: An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function

Why could i get an Unhandled exception Access violation writing in c++/CLI?

微笑、不失礼 提交于 2019-12-04 15:31:42
I have been struggeling writing a solution excisting out of an c++ win32console and a c++ dll. i finally managed to get them talking without linker errors (so i am assuming both are fully managed c++/CLI projects) but when i run the console i get the following error. Unhandled exception at 0x03f71849 in Company.Pins.Bank.Win32Console.exe: 0xC0000005: Access violation writing location 0x00000001. The console also shows the following Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at wmain in c:...\win32console.cpp:line 20 at

Marshalling C++ pointer interface back though C# function call in a non default AppDomain

前提是你 提交于 2019-12-04 14:57:36
I have a working CLI interface between C++ and C# code. The code has a C++ abstract interface like: -------------C++ Interface--------------- namespace cppns { class cppInterface { public: virtual bool Start(const char *pcDir) = 0; }; } ------Implementation of abstract C++ interface in same dll--------- namespace cppns { class cppimp : public cppInterface private: gcroot<MyInternalCSharpClass^> mInternalClassAccess; public: cppimp::cppimp() { mInternalClassAccess = gcnew MyInternalCSharpClass(); } virtual bool cppimp::Start(const char *pcDir) { System::AppDomain ^appDom = AppDomain:

C++/CLI equivalent of C# checked keyword

好久不见. 提交于 2019-12-04 14:54:18
Is there a way for managed code in C++/CLI to throw exceptions on arithmetic overflow? C# has the checked keyword and also global project flags to enable these, but I can find neither in C++/CLI... My situation is that I am wrapping C++ libs in .NET. Sometimes the C++ native code overflows. I was/am considering moving some sensitive calculations to existing C++/CLI wrapper, but perhaps this is not possible? Hans Passant The linked duplicate make no sense, C++/CLI follows C++ conventions. C++ has no built-in mechanism for detecting arithmetic overflow. Using the checked and unchecked keywords

Is the VC++ code DOM accessible from VS addons?

倖福魔咒の 提交于 2019-12-04 14:54:10
问题 Visual Studio IntelliSense for VC++ includes the "complete" EDG C++ parser (also used by Intel and others). Since the C# Code DOM is accessible to addons (correct me if I'm wrong), is the C++ Code DOM also accessible? Can this be used to analyse an open VC++ project within the VS environment? 回答1: The Visual C++ Refactoring extension is able to rename a member project-wide. Its built by MS but obviously they used the internal Code DOM to achieve this. So it is possible, I just don't know how,

AccessViolation, when calling C++-DLL from C++/CLI

限于喜欢 提交于 2019-12-04 14:16:11
I've written a C++/CLI wrapper for a C++-DLL to use this DLL in a C# programm. However, when I call a function, which takes a char* I get a AccessViolation int Wrapper::Net_methodX(int a, String^ key, long v) { IntPtr ptr = Marshal::StringToHGlobalAnsi(key); pin_ptr<char> cKey = static_cast<char*>(ptr.ToPointer()); int val = methodX(a,cKey, v); // AccessViolation here Marshal::FreeHGlobal(ptr); return val; } The signature of the C++-function is int methodX(int a, char *Key, long v); EDIT 1 Just to "pin" like the following didn't work either: int Wrapper::Net_methodX(int a, String^ key, long v)