c++-cli

What are the advantages of doing 100% managed development using C++/CLI?

不想你离开。 提交于 2019-11-30 05:17:27
What are the advantages (the list of possible disadvantages is lenghtly) of doing 100% managed development using C++/CLI (that is, compile with /clr:safe which "generates ... assemblies, like those written in ... C#")? Especially when compard to C# (note C++/CLI : Advantages over C# and Is there any advantage to using C++/CLI over either standard C++ or C#? are mostly about managed/unmanaged interop). For example, here are a few off the top of my head: C++-style references for managed types , not as elegant as full blown non-nullable references but better than nothing or using a work-around .

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

安稳与你 提交于 2019-11-30 04:49:44
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. BlueRaja - Danny Pflughoeft % 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 can move CLR objects around, so a CLR-object's memory address may change. The ^

New .NET 2.0 C++/CLI project has implicit dependency on mscorlib v4?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 04:49:37
问题 I created a new C++/CLI project in Visual Studio 2012, with .NET 2.0 selected as the framework on the project creation page. I have verified the "External Dependencies" (mscorlib.dll, System.Data.dll, System.dll, and System.XML.dll) show "Path" as being c:\Windows\Microsoft.NET\Framework\v2.0.50727\* . When adding a reference to this project from a C# .NET 2.0 project in the same solution, at build time the compiler cannot link against my C++ library with the following error: Warning 2 The

C++ Interop: How do I call a C# class from native C++, with the twist the class is non-static?

久未见 提交于 2019-11-30 04:03:58
I have a large application written in native C++. I also have a class in C# that I need to call. If the C# class was static, then it would be trivial (there's lots of examples on the web) - just write the mixed C++/CLI wrapper, export the interfaces, and you're done. However, the C# class is non-static, and can't be changed to static as it has an interface (the compiler will generate an error if you attempt to make the C# class static). Has anyone run into this problem before - how do I export a non-static C# class to native C++? Update 2010-11-09 Final solution: tried COM, this worked nicely

C# to C++/CLI to C DLL System.IO.FileNotFoundException

一世执手 提交于 2019-11-30 04:02:23
问题 I'm getting System.IO.FileNotFoundException: The specified module could not be found when running C# code that calls a C++/CLI assembly which in turn calls a pure C DLL. It happens as soon as an object is instantiated that calls the pure C DLL functions. BackingStore is pure C. CPPDemoViewModel is C++/CLI calling BackingStore it has a reference to BackingStore. I tried the simplest possible case - add a new C# unit test project that just tries to create an object defined in CPPDemoViewModel .

How do I call C++/CLI (.NET) DLLs from standard, unmanaged non-.NET applications?

落爺英雄遲暮 提交于 2019-11-30 03:29:21
问题 In the unmanaged world, I was able to write a __declspec(dllexport) or, alternatively, use a .DEF file to expose a function to be able to call a DLL. (Because of name mangling in C++ for the __stdcall, I put aliases into the .DEF file so certain applications could re-use certain exported DLL functions.) Now, I am interested in being able to expose a single entry-point function from a .NET assembly, in unmanaged-fashion, but have it enter into .NET-style functions within the DLL. Is this

How to use Nullable types in c++/cli?

浪尽此生 提交于 2019-11-30 03:12:50
I have the following code, which I thought would work: property Nullable<double> Angle { Nullable<double> get() { return nullptr; } } It doesn't. How can I do it? Does c++/CLI even support nullable types? OK, found it, after a lot of hassle: to return null, just do return Nullable<double>(); to return non-null: return Nullable<double>(12321); It is important to declare the return value as Nullable<double> and not Nullable<double>^ , as if you do it, when using other languages as C# and vb.net, you'll see the type as ValueType instead of double? . 来源: https://stackoverflow.com/questions/1457723

When should delete be called on a gcnew allocated object?

时光毁灭记忆、已成空白 提交于 2019-11-30 03:07:05
问题 I was reading the following MSKB example and they perform a delete on a managed object. I was under the impression you should never delete a garbaged collected object rather you must leave that to garbage collector. What have I missed? Method 4 //#include <msclr/marshal.h> //using namespace msclr::interop; marshal_context ^ context = gcnew marshal_context(); const char* str4 = context->marshal_as<const char*>(str); puts(str4); delete context; 回答1: delete in C++/CLI merely calls the Dispose

C++/CLI : Advantages over C#

[亡魂溺海] 提交于 2019-11-30 03:03:04
问题 Is there any major advantage of managed C++/CLI over C#. Definitely not the syntax I suppose as the following code in C++/CLI is real ugly, C++/CLI code: [Out]List<SomeObject^>^% someVariable Compare above with C# Code: out List<SomeObject> someVariable Just out of curiosity, is there an even uglier syntax in C++/CLI as compared to the above. 回答1: It's almost exclusively an interopability language - both for allowing .Net code to access legacy C++ libraries, or for extended existing (native)

Why is Intellisense “Unavailable for C++/CLI”? [duplicate]

↘锁芯ラ 提交于 2019-11-30 02:29:52
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: No IntelliSense for c++/cli in visual studio 2010? As the title already states, nothing gets popped up or syntax checked. In the status bar, the following message is displayed. Intellisense 'Unavailable for C++/CLI' Usually I am using native C++ in Visual C++ 2010 Express. In Visual C++ 2008, Intellisense was working correctly for C++/CLI, so I guess it should be working in this version too. 回答1: The