c++-cli

Threadpool execution delay doubt

Hi, I have invoked BeginInvoke on 10 delegates in a loop. Instead of using 10 threads, the threadpool uses only two/three threads for executing the delegates. Can somebody please explain the reason for this?. The delegate execution takes only a few ms (less than 10ms). When I logged threadpool parameters before invoking BeginInvoke it...

How is marshalling performed when C++ code is called from C++/CLI?

According to this question it's possible to seamlessly combine managed and unmanaged code using C++/CLI. I don't quite get it - shouldn't there be marshalling between managed and unmanaged anyway? For example, I have InnerLibrary that is compiled as a native C++ .dll with a header published and C++/CLI OuterLibrary that calls code from ...

Read namespaces from xml document

hi, how do I read namespaces from the XML document? <fx:FIBEX xmlns:fx="http://www.asam.net/xml/fbx" xmlns:can="http://www.asam.net/xml/fbx/can" xmlns:flexray="http://www.asam.net/xml/fbx/flexray" xmlns:ho="http://www.asam.net/xml" xmlns:ni="http://www.ni.com/xnet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...

Referencing a C++/CLI assembly from an XNA Project

I've recently been tasked with porting a large codebase of C++ code to XNA, specifically .Net v4 Client Profile. My hope was to use C++/CLI rather than translating all the code to C#, but in my feasibility tests, it looks like you can't reference non-XNA projects from XNA, and there's no way to create a C++/CLI XNA project. I've set the...

Can't register for event because function not marked as serializable. Can't mark function as serializable.

I have a function that I want to use as an event handler: void singleFrameEventHandler(void) { SetEvent(g_hSingleFrameArrived); } However, when I try to register for the event: iaframe->OnNewFrame += gcnew newFrame(&singleFrameEventHandler); The following exception is raised: An unhandled exception of type 'System.NotSuppor...

ref and out in C++/CLI

Hello I know that the C++/CLI code void foo(Bar^% x); transforms into Void foo(ref Bar x); What is the C++/CLI code that becomes Void foo(out Bar x); ? ...

Given the following class definition that is designed to emulate an array of integers :

class array { int * ptr ; int length ; void realloc (int) ; public : // all public functions declarations }; and the main( ) function : int main( ) { const int dim = 5 ; array a; a.initialize(dim); a.print(); for ( int I = 0; I < a.get_length() ; i++) a.store(i , i); a.print(); a.increment(); a.append(6); a.print(); a.reve...

Pointer to managed array in C++/CLI

Alright, I know how you normally would declare a pointer: void SomeFunction(array<float> ^managedArray) { pin_ptr<float> managedArrayPtr = &managedArray[0]; } This works fine except when managedArray contains no elements. In that case, it throws an IndexOutOfRangeException. In C# you can do this: void SomeFunction(float[] managedA...

protobuf-net not deserializing array of sbyte

I have a class defined in C++/CLI as such: literal Int32 BufferLength = 4000; Message() { num1 = 0; num2 = 0; str1 = String::Empty; buffer = gcnew array<System::SByte>(BufferLength); }; [ProtoMember(1)] property double num1 { double get() { return _num1; } void set(double value) { _num1 = value; } } [ProtoMember(2)]...

Is there any Visual C++ compiler for linux supporting most of VS Visual C++?

Is there any Visual C++ compiler for linux supporting most of VS Visual C++? If there is no such what is best alternative for porting\adapting your visual C++ code to? ...

How can I view the elements of a System::ComponentModel::BindingList while debugging

I am using Visual Studio 2005 where my code is a mix of C++-CLI and C#. I would like to be able to view the members of a BindingList at a breakpoint while debugging. Currently, I cannot find where the actual elements are stored via the watch browser. Is this possible? ...

Why Inline asm in C++/CLI creates horrible problem?

Hello, I am using Inline asm in C++/CLI. Horrible problem infact could be a bug I obsereved. I passed vector from one function call to another. If I comment the whole code snippet of _asm{....some assembly code here} inside the called function where vector used which are provided to it from other function, then no problem whole vector...

Converting c++ project to clr safe project

Hi, I need to work on converting a very huge c++ project to clr safe. The current c++ project has a lot of stuff from c++ like templates, generics, pointers, storage/stream, ole apis, zlib compression apis, inlines etc. Where can I find the datiled document for this type of conversion? Can you suggest some good book to refer to? If anyo...

How do I gracefully close another application?

I have a CLI/C++ based install application which needs to close another app I've written, replace the application's .exe and dlls and the re-run the executable. First of all I need to close that window along the following lines: HWND hwnd = FindWindow(NULL, windowTitle); if( hwnd != NULL ) { ::SendMessage(hwnd, (int)0x????, 0, NULL...

Is there any way I can create a System::Type object representing a DateTime object without a DateTime object?

Wanted for property grid, in the PropertyType function of the class derived from PropertyDescriptor, but I don't want an actual DateTime object - I'll just convert it to and from String in SetValue and GetValue. ...

How do I debug Windows Forms Designer crashing?

I have a windows forms project. It has a main form derived from System::Windows::Forms::Form which I can open in designer without any problems. If I try and close designer though, it kills Visual Studio (v2008 with SP1). The form includes a tab control which has pages with various System::Windows::Forms::UserControl derived forms. So I'...

Why is my custom property grid not showing a file name picker?

I derived a class from ICustomTypeDescriptor, and in the GetProperties method I return a PropertyDescriptorCollection collection of CustomProperty. Here is the relevant part of my CustomProperty class: (i know it's a bit crude, but everything else works including the DateTime picker) ref class CustomProperty : PropertyDescriptor { ...

Why is a control destroyed twice when it's nested in a tab control?

I've been trying to debug why closing windows forms designer is crashing visual studio and have discovered by adding a series of message boxes that if my controls are nested inside a System::Windows::Forms::TabControl the destructor of those controls are called twice. Is that expected behaviour and is there a way of avoiding it? ...

How can I mix the Concurrency Runtime with .NET code?

I've been using the Concurrency Runtime in a C++ static library, and recently wanted to use this library in a C++/CLI project, to take advantage of the Windows Form designer and avoid MFC. Unfortunately, the Concurrency Runtime is not compatible with the /clr switch required in C++/CLI. I tried surrounding the included header files that ...

What are main difrences between * ^ and & in visual-C++ 2010?

What are main difrences between * ^ and & in visual-C++ 2010? ...