c++-cli

How do I display an MFC control in a windows forms application?

倖福魔咒の 提交于 2019-12-01 08:20:14
I'd like to create a windows forms control which shows an MFC control such as CIPAddressCtrl , with a working Text property and TextChanged event. How do I display an MFC control in a windows forms application? I'm happy to use C++/CLI if necessary. NOTE: I'm not asking how to create a brand new windows forms control; I want to host a legacy control in a windows forms app. This article presents a solution which will wrap your MFC control. The neat trick of this is its use of SubclassWindow in the override of Control::OnHandleCreated. The rest of the code involves manually wrapping the

Mixing managed and unmanaged C++ code?

假装没事ソ 提交于 2019-12-01 08:03:14
问题 I have a couple specific questions regarding mixing managed C++ with unmanaged C++: If I leave out ref and value in a class/struct declaration, does that automatically make the class/struct unmanaged? Or do I still need to include the #pragma unmanaged and #pragma managed directives? How compatible are unmanaged and managed types? For example, I can have an unmanaged object in a managed class, right? Can I pass an unmanaged class/struct to a managed function (ie. pass a std::string to a

How do I compile C++/CLI code for Silverlight?

こ雲淡風輕ζ 提交于 2019-12-01 07:39:24
I have a C++/CLI library that I would like to use in a Silverlight application. It is supposed to be possible to write code for Silverlight in any .NET language, but so far I've only worked out how to compile C#. Silverlight does not seem to be able to use DLLs compiled for .NET. I'm using Visual Studio 2010 and Silverlight 4. The only new projects available for Silverlight are C# projects. Porting the code to C# is not a practical option. How do I compile C++/CLI code for Silverlight? I think I may have gotten a VS2010 C++/CLI class library project to build with references to (only)

C++/CLI: Use LoadLibrary + GetProcAddress with an exe

江枫思渺然 提交于 2019-12-01 07:33:06
Up until now, I had some sort of plugin mechanism in which I loaded dlls using LoadLibrary and GetProcAddress to create a concrete object and return a common interface. This worked fine until I decided that one of the dlls should be an exe. LoadLibrary's documentation says that it can be used for exe's as well, so I gave it a shot. The exe gets loaded without errors, as GetProcAddress. But when I try to call my concrete object's constructor, I get an access violation. I thought this would happen because loading an exe does not load all the dlls it uses. So I tried loading them using

C++\CLI applicatin crash on load

女生的网名这么多〃 提交于 2019-12-01 07:04:11
问题 I have a C++ app that loads lot of C++ DLL and few selected C++\CLI ones. On one of the machines (Windows Server 2003 SP2) on start-up I was getting error message The application failed to initialize properly (0xC0000005). Click on OK to terminate the application. When app was opened with WinDbg instead of getting proper DbgBbreak breakpoint I was getting this: Microsoft (R) Windows Debugger Version 6.12.0002.633 X86 Copyright (c) Microsoft Corporation. All rights reserved. CommandLine: d:

Pass Managed Function Pointer As Unmanaged Callback

烈酒焚心 提交于 2019-12-01 06:35:07
I am attempting to pass a managed function pointer void (*)(void *) to my unmanaged library. My unmanaged library calls this callback with a pointer to a frame of data protected by a CriticalSection. While the managed callback is running, nothing else can modify the frame of data due to the Critical Section. However, I am getting Access Violations and Heap Corruptions just by entering the callback. EDIT : I forgot to mention. The StartStreaming() steals the thread it manages. Furthermore, it creates a separate thread for dispatching new data to the given callback. The callback is called in

Remote debugging an app with the DEBUG versions of the CRT when VS is not installed on the remote machine

时光毁灭记忆、已成空白 提交于 2019-12-01 05:53:21
First let me say that I can remote debug a release build on the remote computer. I set up my release build much like my debug build but I mostly had to make sure the Debug flag was not set. I've dealt with doing this for a while and finally decided to try and figure out why I had to go through this. I should also mention that my remote debugging experience is limited to this project and the C# program uses a C++/CLI (built with /clr) .DLL to mediate to some critical C++ libs. I don't need to debug the underlying C++ libs but I do need to debug the C++/CLI code. (One reason I mention this is I

Why does printf work with managed Strings?

痴心易碎 提交于 2019-12-01 05:48:19
we are currently digging through some really old C++/CLI-Code (Old Syntax .NET Beta) and were a bit surprised to see something like this: System::String ^source("Test-String"); printf("%s", source); The program correctly outputs Test-String We are wondering, why is it possible to pass the managed string source to printf - and more importantly: Why does it work ? I don't expect it to be some convenience-feature by the compiler because the following doesn't work: System::String ^source("Test-String"); char pDest[256]; strcpy(pDest, source); This produces a (somehow expected) compiling error

How do you 'cancel' a UdpClient::BeginReceive?

我与影子孤独终老i 提交于 2019-12-01 04:50:49
I have a thread which sits around waiting for UDP messages from multiple interfaces using UdpClient::BeginReceive and a callback which calls UdpClient::EndReceive to pick up the data and pass it on. If after 5 seconds I don't get anything, I return from the function which calls UdpClient::BeginReceive so that the process can be cancelled and to issue another broadcast which would trigger external clients to send in UDP responses. If we're not cancelling, I call the UdpClient::BeginReceive function again to check for new data. If the client hasn't received any data in time, is there a way to

How do I compile C++/CLI code for Silverlight?

我的未来我决定 提交于 2019-12-01 04:47:14
问题 I have a C++/CLI library that I would like to use in a Silverlight application. It is supposed to be possible to write code for Silverlight in any .NET language, but so far I've only worked out how to compile C#. Silverlight does not seem to be able to use DLLs compiled for .NET. I'm using Visual Studio 2010 and Silverlight 4. The only new projects available for Silverlight are C# projects. Porting the code to C# is not a practical option. How do I compile C++/CLI code for Silverlight? 回答1: I