c++-cli

Why is destructor for a form called twice?

喜夏-厌秋 提交于 2019-12-31 02:13:08
问题 This code with entry point calls form's destructor twice. void Main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); MyApp::MyForm form; Application::Run(%form); } I have changed it to void Main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Run(gcnew MyApp::MyForm); } The second version calls destructor one time only. Why initially was it called

Namespace not recognized in C++/CLI

懵懂的女人 提交于 2019-12-31 02:10:51
问题 I asked this question recently: create a namespace in c++/cli? and so I am trying to create my own namespace in c++/cli. But when I use the same namespace in two separate files (.cpp), the namespace is clearly not recognized as being the same because I get errors when I try to reference the other class in the other file. Here's basically what I have: Pets.cpp: namespace Animals { public ref class Pets { public: List<Dog> ^vDogs; Pets::Pets() { vDogs = gcnew List<Dog^>(); } void Pets:

Using TagLib in Visual Studio 2010

*爱你&永不变心* 提交于 2019-12-30 07:32:46
问题 EDIT: Yes, I have looked at this post. Unfortunately, it looks like the user ends up using MingW in the end. I am on Windows 7 , 64-bit. I downloaded the most recent version of the TagLib code from the SVN repository. I am using revision 1202935 . I am trying to use TagLib in Visual Studio 2010 . I have gotten TagLib to work with QtCreator/MingW, but I want to start learning the Windows API so I am starting from scratch in Visual Studio 2010 (C++ of course). In VS2010, I have build zlib (both

Using TagLib in Visual Studio 2010

无人久伴 提交于 2019-12-30 07:31:08
问题 EDIT: Yes, I have looked at this post. Unfortunately, it looks like the user ends up using MingW in the end. I am on Windows 7 , 64-bit. I downloaded the most recent version of the TagLib code from the SVN repository. I am using revision 1202935 . I am trying to use TagLib in Visual Studio 2010 . I have gotten TagLib to work with QtCreator/MingW, but I want to start learning the Windows API so I am starting from scratch in Visual Studio 2010 (C++ of course). In VS2010, I have build zlib (both

Target .NET 3.5 C++/CLI in Visual Studio 2010 Beta 2

我怕爱的太早我们不能终老 提交于 2019-12-30 07:10:48
问题 Has anyone had any success converting a VS 2008 C++/CLI (vcproj) project to a VS 2010 project (vcxproj), whilst maintaining .NET 3.5 as the target framework? I haven't been able to do this and get the project to build successfully. The project compiles fine in VS2008 as .NET 3.5, and fine in VS2010 as .NET 4.0, but I am unable to target .NET 3.5 in 2010. The IDE doesn't seem to provide an option for it, and modifying the vcxproj file by adding <TargetFrameworkVersion>v3.5<

What type of project needs to be created for C++/CLI?

一曲冷凌霜 提交于 2019-12-30 06:42:06
问题 I am writing a wrapper for my native C++ methods in C++/CLI which will expose them to C#. Now I am using Visual Studio 2008. Can any one tell me what type of project I need to create so that my wrapper will be exposed to C#. I see in Visual Studio 2008 there are different types of projects under Visual C++--->CLR----> class library, CLR Empty Project, Windows form control library, CLR Console Application, Windows Forms Application, Windows Service Which one should I use? 回答1: You have to

Linker error when using unique_ptr in C++/CLI

巧了我就是萌 提交于 2019-12-30 06:25:26
问题 I'm currently converting my instances of auto_ptr to unique_ptr , but I'm hitting an issue. It works great in the C++ part of the code, but when doing it in my managed C++/CLI layer (the software uses both C# and C++) I get link errors. It compiles fine, but it breaks at link time. There were never any issues with auto_ptr . I'm currently using Visual Studio 2010. Does anybody know of any issues with using unique_ptr in C++/CLI? I've tried to sum up my issue in a piece of code below, but

How do I export class functions, but not the entire class in a DLL

别等时光非礼了梦想. 提交于 2019-12-30 02:26:05
问题 I have developed a Win32 DLL, providing the details below, and want to create a CLI/C++ wrapper for the functions Connnect and LogOut. I know that entire classes and functions can be exported from a DLL. class CClientLib { public: CClientLib (void); // TODO: add your methods here. __declspec(dllexport) bool Connect(char* strAccountUID,char* strAccountPWD); __declspec(dllexport) void LogOut(); private : Account::Ref UserAccount ; void set_ActiveAccount(Account::Ref act) { // Set the active

What does the C++/CLI Object^% (caret percent-sign) declaration mean?

江枫思渺然 提交于 2019-12-30 01:00:11
问题 This apparently is a Google-proof term since I can't get any search engines to not throw away the "extra" characters. I did also look on MSDN in the C++ reference but I can't seem to find the C++/CLI reference because there is nothing in the declarations section on it. 回答1: % is a tracking reference. It is similar to a native reference ( Object& ), but a tracking reference can reference a CLR object while a native reference cannot. The distinction is necessary because the garbage collector

How do I specify a fixed-size buffer in C++/CLI?

独自空忆成欢 提交于 2019-12-29 07:47:06
问题 In C#, I can specify a fixed sized buffer using the fixed keyword, like so: public unsafe struct StructWithFixedBuffer { public fixed char FixedBuffer[128]; } how would I express the same thing in C++/CLI? 回答1: One of the C++/CLI developer blogs had code for a template solution to this, I'll try to find a link. Ahh, found it. It's called inline_array. 回答2: The C# syntax was added as a way to express the C++ syntax you've know forever. :) public: wchar_t FixedBuffer[128]; 回答3: Quote: size of