c++-cli

How to forward overloaded constructor call to another constructor in C++/CLI

I know that there is no way to do this in pure C++, but I was wondering if it is possible to call a constructor from another constructor's initialization list in C++/CLI, same way one can do it in C#. Example: ref class Foo { Foo() {} Foo(int i) : Foo() {} } ...

Is it possible to create a static dictionary in a C++/CLI environment?

I used in my C++/CLI project static array's like: static array < array< String^>^>^ myarray= { {"StringA"}, {"StringB"} }; Is it possible to create a dictionary the same way? I was not able to create and initialize one. static Dictionary< String^, String^>^ myDic= { {"StringA", "1"}, {"StringB", "2"} }; Thx ...

Why does .NET dislike this C++/CLI template function?

In a plain vanilla WinForms app (C++/CLI, set to /clr), I have the following template function, flagged as "unmanaged": #pragma managed(push, off) #include <string> template< class c > const c& test_alloc() { static c test_alloc; return test_alloc; } #pragma managed(pop) Then in main, I use it before Application::Run(): test_al...

.NET Framework - Per Application Overhead

Does anybody have any concrete information on the overhead of using the .NET Framework 2.0/3.0/3.5? I am mostly interested in per-instance overhead and whether there is a "fixed cost" regardless of the number of instances, e.g. in a Terminal Services environment with 300 instances of a .NET Framework application running is there only 1 ...

What multithreading paradigm is described here?

A snippet from Managed Threading Best Practices on MSDN: Don't control the execution of worker threads from your main program (using events, for example). Instead, design your program so that worker threads are responsible for waiting until work is available, executing it, and notifying other parts of your program when finished. If you...

How to register a user in desktop application using visual c++ / CLI

I have created an application using C++/CLI. I have to register user when he enters a License key. The user can be connected to internet or may be offline. Can some one guide me how to approach following task. ...

Open New Form. error c3767 candidate function(s) not accessible

Hi, I want to open one form from another. I'm having no troubles doing this with blank project. Start new, make 2 forms, put button on first, use this code Form2 ^ form = gcnew Form2; form->ShowDialog(); Also adding the include file at the top... I'm getting this error error c3767 candidate function(s) not accessible I've gone th...

Should I implement IDisposable to free "unmanaged" memory?

Let's say I'm implementing some wrapper class Foo in C++/CLI. Naturally if I'll create a dtor (Foo::~Foo), it'll become an IDisposable implementation. IDisposable is typically used to allow immediate release of some "scarce" resource: GDI resources, file handles etc. However, if my IDisposable simply frees memory (e.g. it simply perform...

Succinct introduction to C++/CLI for C#/Haskell/F#/JS/C++/... programmer

Hello everybody, I'm trying to write integrations with the operating system and with things like active directory and Ocropus. I know a bunch of programming languages, including those listed in the title. I'm trying to learn exactly how C++/CLI works, but can't find succinct, exact and accurate descriptions online from the searching th...

How to check an object's type in C++/CLI?

Is there a simple way to check the type of an object? I need something along the following lines: MyObject^ mo = gcnew MyObject(); Object^ o = mo; if( o->GetType() == MyObject ) { // Do somethine with the object } else { // Try something else } At the moment I'm using nested try-catch blocks looking for System::InvalidCastExc...

C++ vs. C++/CLI: Const qualification of virtual function parameters

[All of the following was tested using Visual Studio 2008 SP1] In C++, const qualification of parameter types does not affect the type of a function (8.3.5/3: "Any cv-qualifier modifying a parameter type is deleted") So, for example, in the following class hierarchy, Derived::Foo overrides Base::Foo: struct Base { virtual void Fo...

What is the point of C++/CLI?

Hello, I am wondering what the uses of C++/CLI is. It seems to me that it is basically C++ running on .Net, am I wrong in this thinking? What is it good for? Why not just use C# or some other truly managed language instead? ...

How to get full intellisense tooltip comments working?

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): ...

How to only use a specific amount of threads in the threadpool at any given time

I found this question that was very useful in learning the basics of the ThreadPool. Now my questions lies in using the ThreadPool for a series of "tasks", like the Fibonacci class, but wanting to have at most n number of these tasks executing at any one time, or basically limiting these tasks as they execute in the ThreadPool to a ma...

Pointer to "value struct x"

How do I dynamically allocate a value struct and get a pointer to it? If I have: value struct x { String ^myString; }; I can do this: x vsInstance; x *pvs = &vsInstance; // "Unmanaged pointer" to managed object And I can do this: x ^vsInstance = gcnew x; But I can't do this: x *pvs = new vsInstance I need a * pointer rat...

Why isn't my static member function recognised across assemblies?

I have a helper assembly which includes a function to identify object types: namespace Util { using namespace System; public ref class CastingHelpers { public: template < class T, class U > static System::Boolean isinst(U u); static bool Test() {return true;} }; } ...but for some reason, ...

Loading a 3.5 compiled C++/CLI application in .NET 4.0

I'm trying to load a mixed managed application compiled and targeted for Framework 3.5 in the 4.0 CLR. We have a .config file next to the .exe where I've added this node: <?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0.21006" /> </startup> Unfortunately, the app crashes out on startup with a nasty...

How to explicitly/implicitly implemented interface members in C++/CLI?

What's the equivalent in C++/CLI of this: class Explicit : IClonable { void IClonable.Clone() { } } class Implicit : IClonable { public void Clone() { } } ...

How to know if a C++/CLI reflected parameter is long or int?

I'm reflecting a C++/CLI method that has the following signature: void foo(long n); This translates into C# as: void foo(int modopt(IsLong) n); How can I find if an int parameter is actually a C++/CLI long by reflection? ...

call c++ function with reference parameter from cli

The unmanaged function(pure c++): void fooC(float& result); I define the wrapper as (managed wrapper, c++\cli): void foo(float% result) //managed interface, need to pass result back to caller { fooC(???);//how to call unmanaged function? } how to pass reference parameter in the wrapper? ...