c++-cli

MFC C++/CLI project: /CLR switch in VS2012 causes debugging issues

£可爱£侵袭症+ 提交于 2019-12-10 12:10:10
问题 The company has upgraded our IDE from VS2008 to VS2012. When I try to debug my C++/CLI project (created with VS2008), I no longer seem to see items such as the 'this' pointer, STL containers, data members in structures, etc. From VS2012, I tried to create a new MFC "Multiple documents" project and set a breakpoint at the end of its CMainFrame::OnCreate(). Everything is fine when I debug, but as soon as I enable /CLR, I get the issue described above. Is there a new switch in VS2010/VS2012 that

Why can't I load an image resource from my resx file?

笑着哭i 提交于 2019-12-10 12:04:46
问题 I have a controls library which I've added a .resx file to (ImageResources.resx). It contains two .png images which I subsequently added. In that same library I have a control which loads a couple of images to do some custom drawing, but I don't seem to be able to load the resources: void GTableLayoutPanel::SetBorderImagesFromManifest(String^ topLeftCornerImageName, String^ topImageName) { // Grab the assembly this is being called from Assembly^ assembly = Assembly::GetExecutingAssembly(); //

Transferring vector of objects between C++ DLL and Cpp/CLI console project

点点圈 提交于 2019-12-10 11:13:51
问题 I have a C++ library app which talks to a C++ server and I am creating a vector of my custom class objects. But my Cpp/CLI console app(which interacts with native C++ ), throws a memory violation error when I try to return my custom class obj vector. Code Sample - In my native C++ class - std::vector<a> GetStuff(int x) { -- do stuff std::vector<a> vec; A a; vec.push_back(a); --- push more A objs return vec; } In my Cpp/CLI class public void doStuff() { std::vector<a> vec; vec = m_nativeCpp-

C++/CLI noob: System.AccessViolationException

耗尽温柔 提交于 2019-12-10 10:57:55
问题 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

Write logs in Visual Studio 2008

泄露秘密 提交于 2019-12-10 10:49:17
问题 I am writing application on C++ .NET in Visual Studio 2008. I want to ask if there is standard function for writing logs ? Edited it mean I can write such code and where I can see output logs ? #ifdef DEBUG Trace::Write("Message", "Category"); #endif 回答1: Trace::Write("Message", "Category"); Debug::Write("Message", "Category"); // Same thing as #ifdef DEBUG Trace::Write(...) is pretty much the prebuilt logging facility. To get the output to a file, append the below configuration to your app

Silverlight and C++ or C++ to C# ongoing code conversion?

限于喜欢 提交于 2019-12-10 10:33:42
问题 I am working on a drawing-based product where I want to produce versions for iPhone, desktop OS/X, Windows Tablets, Silveright-based browser, Windows Mobile, and Windows in that order of priority. For GUI portability, the classic answer is to keep the core in C++ and use Cocoa/Objective-C or WPF/C# thin layers. However, Silverlight complicates the choices. I wouldn't have any problem migrating my code into C++/CLI and maintaining a dual code base (with some macros to fake the C++/CLI

Visual C++: Unable to invoke method from another class

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:18:10
问题 Please have a look at the following code Form1.h #pragma once #include "Clicker.h" namespace TestWindowProject { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the

How to pass a C++ short* to managed C# assembly in C++/CLI

那年仲夏 提交于 2019-12-10 09:54:53
问题 I'm having trouble passing an argument from C++/CLI code into a .NET C# function. In C++ I have something resembling the following: void SomeFunction(short *id) { CSharpClass::StaticClassInstance->SetValue(id); } On the C# side, the function is declared with a ref argument as: public void SetValue(ref short id) { id = this.internalIdField; } The compiler error I'm getting when calling SetValue(id) is "cannot convert parameter 1 from 'short *' to 'short %'". I found out that a tracking

How to consume an awaitable in C++/Cli

江枫思渺然 提交于 2019-12-10 09:21:12
问题 async / await gained a lot of popularity in the C# world the past few years. Async functions also tend to spread rapidly within an application: Awaitables need to be awaited, therefore the calling function must be async and is therefore also an awaitable which needs to be awaited,... and so forth. I'm using a C# library in a C++/Cli project. The library exposes async APIs. The Visual C++ compiler does not support async / await . Hence I have no way to await any of the APIs the library gives

Wrapper For C Static Library

霸气de小男生 提交于 2019-12-10 08:23:04
问题 I Have is C Static Library for Camera. Now Plan is to develop C#/WPF UI for Windows 8 which will use the C static library to capture video/Audio. I came with the idea that there will C++/CLI wrapper for the C Static.The Wrapper will be Managed Dll. C#/WPF UI will use this Dll to Capture the Video/Audio. I wanted to Know whether this approach will be good. Alternate Suggestion is welcome.Please Guys Suggest on this. 回答1: This is indeed a very common solution to the problem. It is generally