c++-cli

extern “C” char** environ - Windows - C++/CLI

半城伤御伤魂 提交于 2019-12-08 03:15:23
问题 I have some old linux code I'm trying to port to Windows. When I first built it as a straight native DLL, I go no issues with this piece of code, but when I tried making it a mixed-mode C++/CLI DLL, I got an unresolved external object error on this: extern "C" char** environ; Why would this work for native and not CLI? Any idea how to work around this, or what it even does? 回答1: That holds the environment variables (PATH, etc, etc). The C standard (if i recall correctly) requires environ to

Marshalling C# structure to C++ Using StructureToPtr

假装没事ソ 提交于 2019-12-08 02:48:48
问题 I have C# class: namespace Models { [StructLayout(LayoutKind.Explicit, Size = 120, CharSet = CharSet.Unicode)] public struct DynamicState { [FieldOffset(0)] public double[] Position; [FieldOffset(24)] public double[] Velocity; [FieldOffset(48)] public double[] Acceleration; [FieldOffset(72)] public double[] Attitude; [FieldOffset(96)] public double[] AngularVelocity; } } and C++/CLI method: Models::DynamicState SomeClassClr::DoSomething(Models::DynamicState ds) { int struct_size = Marshal:

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

与世无争的帅哥 提交于 2019-12-08 02:29:29
问题 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

How to migrate from C++ COM to C++CLI

非 Y 不嫁゛ 提交于 2019-12-08 00:57:27
问题 I have a C++ DLL that exposes stuff via COM. I want to convert it to C++/CLI that exposes a managed interface. Ideally I just add CLI and convert interfaces one by one. So far I haven't succeeded in anything, so I'm looking for a specific strategy. More detail: A long time ago, I created an app using COM to communicate back and forth between C# and C++. I'm sick of COM, and the registration and the hoop jumping needed on the C++ side. I want to use C++/CLI, and get the whole thing working as

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

北战南征 提交于 2019-12-08 00:25:52
问题 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++. 回答1: 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

Calling C# code from visual C++

*爱你&永不变心* 提交于 2019-12-07 23:46:20
问题 Basically I need to call C# code from Visual C++ code. After reading lots of articles about possible ways, I decided I want to use C++/CLI mechanism. Initially I decided I will have some functions in C++ native code (dll library project), they will call some functions from a CLR project which will call some functions from a C# project. After that I thought that maybe I could get rid of the bridge project (the CLR project) since it only makes the transition to managed world. I think that I can

How to get an BITMAP struct from a RenderTargetBitmap in C++/CLI?

为君一笑 提交于 2019-12-07 23:00:44
I've got a WPF RenderTargetBitmap in C++/CLI and I want to be able to create a BITMAP structure from it to use with BitBlt. I've not worked with BITMAP or RenderTargetBitmap much before, so any thoughts would be great! Turns out that it was a little more complicated than simply using CopyPixels. In the C++/CLI managed code, I do the following: virtual BOOL fillBitmap(CDC* dc, CBitmap* bmp) { WPFContainer^ page = getWPFContainer(); // Get a bitmap from the DVE page RenderTargetBitmap ^rtb = gcnew RenderTargetBitmap(page->ActualWidth, page->ActualHeight, 96, 96, PixelFormats::Default); rtb-

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

本小妞迷上赌 提交于 2019-12-07 19:41:23
问题 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;

Using .NET class from native C++ using C++/CLI as a 'middleware'

纵饮孤独 提交于 2019-12-07 18:08:56
问题 I have to use a class/assembly made in C# .NET from native C++ application. I suppose I need to make a wrapper class in C++/CLI, that would expose native methods in header files, but use .NET class as needed. Thing that's unclear to me is how to convert data types from .NET to standard C++ types. Does anybody have some sample code to learn from? Only text I have found on this is: http://msdn.microsoft.com/en-us/magazine/cc300632.aspx But text is very old (using Managed C++, not C++/CLI), and

Calling Java Methods from Visual C/C++ using C++/CLI

纵饮孤独 提交于 2019-12-07 17:40:27
I'm getting a "error LNK1104: cannot open file {path}\jvm.lib" when trying tocompile a VS C++/CLI (managed) project. It's very simple and my goal is to call some Java methods in pre-existing java libs - here is the code I'm using: // This is the main DLL file. #include "stdafx.h" #include <jni_md.h> #include <jni.h> #include "JBridge.h" #pragma once using namespace System; namespace JBridge { public ref class JniBridge { // TODO: Add your methods for this class here. public: void HelloWorldTest() { System::Console::WriteLine("Hello Worldl from managed C++!"); } JNIEnv* create_vm(JavaVM ** jvm)