c++-cli

Value Class in C++/CLI

余生颓废 提交于 2019-11-30 12:44:48
What are the benifits of using a value class in C++/CLI.Can the value class contain member functions? a value class is a ValueType - that means, whenever you assign it to another variable of the same type, the whole object gets copied into the other variable, leaving you with two separate copies. Examples of this are basic numeric data types like int , bool or double . ValueTypes are sealed, which means you cannot derive from them. A ref class is a reference type - if you assign it to another variable of the same type, you copy only a reference. So the two variables basically "point" to the

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

家住魔仙堡 提交于 2019-11-30 12:26:39
问题 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? 回答1: 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

C++/CLI Resource Management Confusion

北城余情 提交于 2019-11-30 11:36:20
I am extremely confused about resource management in C++/CLI. I thought I had a handle (no pun intended) on it, but I stumbled across the auto_gcroot<T> class while looking through header files, which led to a google search, then the better part of day reading documentation, and now confusion. So I figured I'd turn to the community. My questions concern the difference between auto_handle/stack semantics, and auto_gcroot/gcroot. auto_handle: My understanding is that this will clean up a managed object created in a managed function. My confusion is that isn't the garbage collector supposed to do

Convert an IntPtr window handle to IWin32Window^

依然范特西╮ 提交于 2019-11-30 11:17:10
How do I convert a handle acquired from a form/control's Handle property, to a IWin32Window^ ? Control.FromHandle (That gets you the Control object, which implements the IWin32Window interface.) Eg. IntPtr myWindowHandle = IntPtr(someVal); IWin32Window^ w = Control::FromHandle(myWindowHandle); Note that this relies on the handle being "acquired from a form/control's Handle property." You cannot use this technique with an arbitrary Win32 window handle. There's a simpler method that is supported directly by the .NET framework without having to create your own custom class. You can use this with

What is the difference between ANSI/ISO C++ and C++/CLI?

孤街浪徒 提交于 2019-11-30 10:51:01
Created by Microsoft as the foundation of its .NET technology, the Common Language Infrastructure (CLI) is an ECMA standard (ECMA-335) that allows applications to be written in a variety of high-level programming languages and executed in different system environments . Programming languages that conform to the CLI have access to the same base class library and are capable of being compiled into the same intermediate language (IL) and metadata. IL is then further compiled into native code particular to a specific architecture. Because of this intermediate step, applications do not have to be

How to get full intellisense tooltip comments working?

拜拜、爱过 提交于 2019-11-30 10:02:00
I've got some C++/CLI software which is all nice and documented in a C#'ish kind of way which means DOxygen is able to pull it out into some nice html. Is there any way I can get that same information to appear in the intellisense tool tips the way that the .net framework does? For example, lets say this is my header file (MyApp.h): /*************** MyApp.h ***************/ /// My namespace containing all my funky classes namespace MyNamespace { using namespace System; ref class WorldHunger; /// A truly elegent class which solves all the worlds problems public ref class MyClass { public: ///

C++/CLI: how to overload an operator to accept reference types?

六眼飞鱼酱① 提交于 2019-11-30 09:44:26
问题 I am trying to create a CLI value class c_Location with overloaded operators, but I think I have an issue with boxing. I have implemented the operator overloading as seen in many manuals, so I'm sure this must be right. This is my code: value class c_Location { public: double x, y, z; c_Location (double i_x, double i_y, double i_z) : x(i_x), y(i_y), z(i_z) {} c_Location& operator+= (const c_Location& i_locValue) { x += i_locValue.x; y += i_locValue.y; z += i_locValue.z; return *this; } c

error linking to oci libraries from vc++

扶醉桌前 提交于 2019-11-30 09:41:32
问题 Im using the OCI libraries from oracle 9i(personal edtn) for connecting to the database from my c program.(im using visual c++ 2005) ive included all lib files from oci and included them in the additional dependency also, but when i compile the following code i get linker errors. #include "stdafx.h" #include "Form1.h" #include <occi.h> #include<oratypes.h> using namespace ovci; using namespace oracle; [STAThreadAttribute] int main(array<System::String ^> ^args) { oracle::occi::Environment*

what is the C++/CLI syntax to subscribe for events?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 09:14:59
问题 I'm updating some old Managed C++ code with lines like this: instanceOfEventSource->add_OnMyEvent( new EventSource::MyEventHandlerDelegate(this, MyEventHandlerMethod) ); where EventSource is the class that publishes events instanceOfEventSource is an instance of that class EventSource::MyEventHandlerDelegate is the delegate type for the event MyEventHandlerMethod is a (non-static) method within the current class (of which "this" is an instance) with the signature matching EventSource:

Boost Threads with CLR

落花浮王杯 提交于 2019-11-30 08:59:32
Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link the following with the /CLR flag: #include <boost/thread/thread.hpp> void run() {} int main(int argc, char *argv[]) { boost::thread t(run); } The first error is about a forward-declared dummy-struct in boost::thread. This post works around this by declaring: namespace boost { struct thread::dummy {}; } Sure, I now can compile, but then I get the linker warning Warning 1 warning LNK4248: unresolved typeref token (0100001F) for 'boost.detail.win32._SECURITY_ATTRIBUTES'; image may not run Running the application