Managed C++ wrappers for legacy C++ libraries
We're looking at writing a .Net-callable wrapper for some legacy C++ libraries using managed C++. It all looks pretty easy. Is there anything we need to watch out for? ...
We're looking at writing a .Net-callable wrapper for some legacy C++ libraries using managed C++. It all looks pretty easy. Is there anything we need to watch out for? ...
If I use /clr:oldSyntax the following should work: public __value enum IceCreamFlavors { Vanilla, Chocolate, Sardine, }; what is the equivalent in non-oldSyntax? How do I declare a "managed" enum in Managed C++ for .NET 2.0? Edit: when I follow JaredPar's advice, then if I try to pass an IceCreamFlavor to a function with the...
I am going to start implementing some unit tests for a codebase that is a mix of managed and unmanaged C++. Can NUnit hack it with unmanaged code? Is there a better alternative? ...
I figured out through trial n error how to link an unmanaged static library to managed C++ dll, but I have no idea how to dynamically include a DLL. Does anyone know how to do this in Visual studio 2008? ...
Hello, I am using VS 2008 and get compiler errors sporadically when adding a dll reference to a managed c++ file in my C++ project. I am trying to add a reference to the dll so as to be able to use smart pointers. ex: #import items.tlb The problem is that the compiler crashes at sporadic places inside of items.tlh almost as though chun...
What's the prefered way to store binary data in .NET? I've tried this: byte data __gc [] = __gc new byte [100]; And got this error: error C2726: '__gc new' may only be used to create an object with managed type Is there a way to have managed array of bytes? ...
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 typ...
I have an unmanged C++ class I have written in an unmanged dll. I have a managed dll that references the unmanaged dll. Can a class in the managed dll derive from the unmanaged class? Using Visual Studio 2008 ...
I have the STRUCT1 Structure declared as below typedef struct struct1 { short int nbr_fe; [size_is(nbr_fe)] STRUCT2 ptr_fe[*]; } STRUCT1; STRUCT2 is also another structure inside STRUCT1 and then I have a pointer declared to it as below typedef [ptr] STRUCT1 * ptr; And I have to allocate a memory to an array of STRUCT1 b...
This started as a way to find C++/CLI and Managed C++ assemblies so that all classes internal to them could be tested to ensure all inherited methods were being reimplemented. I would like to add this as a build process step to ensure that it never happens again. Thinking about this problem also made me a bit curious as it would be int...
I have a managed c++ project. How do I make the version information of the DLL (as seen in explorer and used by installers) match the version information generated in the Assembly Version atttribute? AssemblyInfo.cpp: [assembly:AssemblyVersion("5.1.*")]; The problem is discussed here. ...
The interfaces in Managed C++ looka bit strange to me since they allow static methods and members inside them. For example, following is a valid MC++ interface. interface class statinterface { static int j; void Method1(); void Method2(); static void Method3() { Console::WriteLine("Inside Method 3"); } ...
trying to wrap a native cpp class using managed c++ class. all looks good but for some reason it wont compile. getting the following linker errors: Error 25 error LNK2028: unresolved token (0A0002CE) Error 27 error LNK2019: unresolved external symbol Any ideas how do I fix this one ? :\ well, here is a full error of one of the ...
Here's the situation: Background I have a mixed mode .NET/Native application developed in Visual Studio 2008. What I mean by mixed mode is that the front end is written in C++ .NET which calls into a native C++ library. The native code does the bulk of the work in the app, including kicking off new threads as it requires. The .NET co...
The windows forms control library project (C++) I writes uses an unmanaged dll. The unmanaged dll has a header file (a Cheshire cat). And I just include it in the control library project. And calls functions in the unmanaged dll (of course with proper marshaling). This compiles and builds. The problem is when I go ahead to add the contro...
An unmanaged C++ dll has an exported function, that takes an int type as window hanlde void SetWindowHandle(int nHandle); else where in the unmanaged dll code the int is casted to HWNDand is used properly. And from the windows forms application, I set the handle as follows _hHandle = this->Handle.ToInt32(); m_pViewer->SetWindowHandl...
I've got a WPF application on an ultrasound machine that displays ultrasound images generated in C++ at a speed upwards of 30 frames per second. From what I understand, the normal process for displaying images in WPF is to create a BitmapSource for your image and set the Source for your Image, which then causes it to invalidate and disp...
In the following example, I get: error C2300: 'UnmanagedClass' : class does not have a finalizer called '!SmartPointer' If I remove the operator->, this error goes away. Could someone explain why this is happening? // Unmanaged class. class UnmanagedClass { }; public ref class SmartPointer { public: SmartPointer(UnmanagedClass*...
I wish to declare and initialize a 1D managed array of items. If it was C# code, I would write it like this: VdbMethodInfo[] methods = new VdbMethodInfo[] { new VdbMethodInfo("Method1"), new VdbMethodInfo("Method2") }; I am trying to write (well, actually, I'm writing a program generate) the same thing in managed C++... So f...
Following up from my previous question. Can anyone explain why the following code compiles without any errors: typedef array<VdbMethodInfo^> MethodArray; typedef array<VdbParameterInfo^> ParameterArray; ParameterArray^ parameters = gcnew ParameterArray { gcnew VdbParameterInfo("name", "string", "Paul")}; MethodArray^ methods = gcne...