c++-cli

How to use C++/CLI to program Winforms applications

我的未来我决定 提交于 2019-12-06 11:54:35
Is there a pdf or video or some media that can inform me on how to program Winforms with C++. Obviously C++ is the most common programming language and I already have some prior knowledge. But when I try to find media about programming in C++, the examples are usually Console applications. I want some media that can teach me how to program Winforms in C++. Here's a tutorial showing how to write Windows Forms applications in C++/CLI . Just be aware that most samples tend to be in C#. Many people purposely use C# for the forms, C++ for their logic, and use C++/CLI to expose their logic as .NET

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

和自甴很熟 提交于 2019-12-06 11:06:08
问题 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

Exception occured While loading dynamically EXE assembly in C++/CLI (Could not load file or assembly ', Version=1.0.3836.39802 …)

别等时光非礼了梦想. 提交于 2019-12-06 10:43:34
I am facing an exception in C++/CLI while dynamically loading assembly which itself creates an EXE in C++/CLI managed mode using Assembly.Load . It successfully loads a DLL assembly, but fails to load EXE assembly and generates the following exception: An unhandled exception of type 'System.IO.FileLoadException' occurred in TestManager.dll Could not load file or assembly 'testAssembly, Version=1.0.3836.39802, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Attempt to load an unverifiable executable with fixups` (IAT with more than 2 sections or a TLS section.) Exception from

Weird scrollbar UI in hosted WPF composite control

ε祈祈猫儿з 提交于 2019-12-06 10:32:29
My windows forms application hosts AvalonEdit (the composite WPF control in question) in one of its forms to cater to its text editing requirements. Here's the code I use: WPFHost = gcnew ElementHost(); TextField = gcnew AvalonEdit::TextEditor(); WPFHost->Dock = DockStyle::Fill; WPFHost->Child = TextField; TextField->Options->AllowScrollBelowDocument = false; TextField->Options->EnableEmailHyperlinks = false; TextField->Options->EnableHyperlinks = true; TextField->Options->RequireControlModifierForHyperlinkClick = true; TextField->ShowLineNumbers = true; ContainerControl->Controls->Add(WPFHost

C++/CLI noob: System.AccessViolationException

倾然丶 夕夏残阳落幕 提交于 2019-12-06 09:50:41
I'm trying to put together a "cool demo" for a career day at my daughter's jr. high in 5 days and so I'm trying to use the echoprint library to perform over the air (OTA) audio recognition. I've never really gone much farther than "hello world" in C++ and I am trying to use C++/CLI to wrap the echoprint codegen library so I can call it from C#. Here's my header file: // echoprint-cli.h #pragma once #include "Codegen.h"; using namespace System; namespace echoprintcli { public ref class CodegenCLI { public: String^ getCodeString(array<float>^ buffer, unsigned int samples, int start_offset); }; }

Wrapper for DOTNET to native written in C++ CLI BestWay to pass structures?

China☆狼群 提交于 2019-12-06 08:32:07
Yet I am writing a wrapper in C++ CLI for our application to give some new parts (written in C#) save and easy access to old native libraries. Therefore I need to pass some structures from C# to C++. These structures are defined in C++ Cli (dotnet) and also in C++. Example: \\C+++ typedef struct { INFO16 jahr ; INFO8 monat ; INFO8 tag ; INFO8 stunde ; INFO8 minute ; } SDATUM; \\c++ cli [StructLayout(LayoutKind::Explicit)] public value struct SDATUM { public: [FieldOffset(0)] UInt16 jahr; [FieldOffset(2)] Byte monat; [FieldOffset(3)] Byte tag; [FieldOffset(4)] Byte stunde; [FieldOffset(5)] Byte

Garbage Collection Across C# and C++/CLI Objects

只愿长相守 提交于 2019-12-06 07:48:48
问题 I'm currently looking into using C++/CLI to bridge the gap between managed C# and native, unmanaged C++ code. One particular issue I'm looking to resolve, is the conversion of data types that are different in C# and C++. While reading up on the use of such a bridging approach and the performance implications involved, I wondered how Garbage Collection would work. Specifically, how the Garbage Collector would handle cleanup of objects created on either side, if they are referenced / destroyed

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

本小妞迷上赌 提交于 2019-12-06 07:25:44
问题 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

Handling Windows Store App exceptions from GetFileAsync

梦想与她 提交于 2019-12-06 06:15:44
问题 I have a problem with the following code example: Windows::Storage::StorageFolder^ location = Package::Current->InstalledLocation; try { task<StorageFile^> GetFileTask(location->GetFileAsync(sn)); GetFileTask.then([=](StorageFile^ file) { try { task<IBuffer^> ReadFileTask(FileIO::ReadBufferAsync(file)); ReadFileTask.then([=](IBuffer^ readBuffer) { // process file contents here }); } catch(Platform::Exception^ ex) { // Handle error here } }); } catch(Platform::Exception^ ex) { // Handle error

Visual Studio 2015 c++/CLI boost::thread [duplicate]

人走茶凉 提交于 2019-12-06 06:05:22
This question already has an answer here : How do I create a C++/CLI Winforms app in VS2012? (1 answer) Closed 2 years ago . This issue has been around for all Visual Studio versions, but in VS 2015 the "old tricks" don't seem to work anymore. This is what I have tried: create a Windows Forms application in VS 2013 and 2015 (the macro is missing since VS 2013, so see this post: Can't find Windows Forms Application for C++ ) add boost headers path to Additional Include Directories add #include "boost/thread.hpp" in the cpp add the following preprocessor definitions (BOOST_USE_WINDOWS_H;BOOST