Hey guys,
I am working on a project now and part of it uses Managed C++. In the managed C++ code, I am creating a DataTable. While defining the Columns for the datatable, I need to specify the Type of the column. In C#, that would:
typeof(int)
but how do I do that in Managed C++?
Thanks!
...
So, I'll be soon working on porting two APIs (C++ and C++/CLI) to use the VS2010 compiler. I think it'd be a good idea to have a head start on this. Any tips?
...
We have a mixed mode assembly that contains both VC++ (using MFC) and C++/CLI classes. It is an MFC Extension dll and is loaded into our MFC executable at runtime and all works well.
When we come to unit test the unmanaged classes in there from another C++/CLI assembly, we see the following exception everytime we try to create an instan...
I have a C++/CLI wrapper around native .lib and .h files. I use the AutoPtr class pretty extensively in the wrapper class to manage the unmanaged objects I create for wrapping. I have hit a roadblock with the copy constructor/assignment operator.
Using the AutoPtr class from Mr. Kerr: http://weblogs.asp.net/kennykerr/archive/2007/03/2...
I recently came across this extremely useful SO question that explains how a native class can be the consumer of managed events.
I have managed to successfully implement this is our codebase. But we're paranoid about unsubscribing from events we have subscribed to, especailly when there are statics involved as we've been burnt by stati...
I am working on wrapping a large number of .h and .lib files from native C++ to Managed C++ for eventual use as a referenced .dll in C#.
Some of the native C++ functions have a return type of void*. I am not sure how to handle this when I pass back the value to my calling code. For instance: if a C# app calls my dll wrapper, what do I ...
hello,
i have a solution, which has a C++ project and a C# project.
the C++ project defines a class, which i want to instantiate in C# and call it's member functions. so far what i managed to do is to instantiate the class:
CFoo Bar = new CFoo();
but when i try to call a function on it, the compiler says, it is not available.
also, w...
In VS2008, I can specify that a C# assembly should target only the x86 platform by going to the project properties, clicking the "Build" section, and then setting the "Platform target" box.
What is the equivalent for an assembly written in C++?
...
Is there a way for me to hook the exit of managed threads (i.e. run some code on a thread, just before it exits?)
I've developed a mechanism for hooking thread exit that works for some threads. Step 1: develop a 'hook' STA COM class that takes a callback function and calls it in its destructor. Step 2: create a ThreadStatic instance of ...
I'm trying to pass this structure:
#pragma unmanaged
typedef struct
{
void* data;
unsigned nlen;
unsigned int type;
} PARAMETER;
To this class static method:
#pragma managed
private class __gc GlobalFunctions
{
static void WriteField(Object* object, PARAMTER& par, unsigned dec)
{
switch (par.type)
{
...
I have a class, A, in C++/CLI which derives from a templated base class, B.
I have some C# code that has an instance of A and wants to call a method on it.
If the method is implemented in A all is fine. If it's implemented in B things get strange.
I knocked up the simplest code that demonstrates what I am trying to do:
C++/ CLI:
templ...
I have a situation where I've wrapped a Native C++ DLL with C++/CLI for eventual use in C#.
There are a few callback functions that are causing some issues at run time. Particularly, I get the following exception:
An unhandled exception of type
'System.Runtime.InteropServices.InvalidOleVariantTypeException'
occurred in ToadWra...
Hello all, I have a 3rd party collection of .h files along with the .lib files that go with them. I am wrapping those native C++ files with a C++/CLI wrapper and making final calls from C#. I have an issue when I call methods that expect a reference to be passed in where the value is not getting changed in my wrapper unless I explicitl...
Hi; I'm trying to build a C++/CLI executable to which I statically link ffmpeg (libavcodec, libavformat, libavutil & swscale). It works fine if I build it normally (without /clr, so no CLR support), it works. However, when I add CLR support, it won't start up with a 0xc000007b. A "Hello World" C++/CLI app runs fine, though.
Supposedly t...
Hi,
First of all I want to make clear that 'm all new to C++, so this might be a simple and somewhat obvious question. In the C++ book I'm reading called C++ Primer, a class is defined by writing:
class classname{
public:
private:
};
However, in VS2008 the compiler didnt like this. But by adding public ref before class, as in:
pub...
Hi,
i'm converting C++ to C++/CLI and would like to expose some managed classes as COM objects. In C# it was easy and setting [ComVisible] & inheriting from interface (also ComVisible) did the job.
However C++ project build as C++/CLI does not export DllRegisterServer.
Here is sample project (started from CLR Console Application proj...
When I build the following C++/CLI code in VS2008, a code analysis warning CA1001 is displayed.
ref class A
{
public:
A() { m_hwnd = new HWND; }
~A() { this->!A(); }
protected:
!A() { delete m_hwnd; }
HWND* m_hwnd;
};
ref class B
{
public:
B() { m_a = gcnew A(); }
protected:
A^ m_a;
};
warning: CA1...
I have run in to this problem of converting a C++/CLI pointer to a native C++ pointer. Heres the background:
I'm writing a windows forms application using C++/CLI. The application makes call into a number of COM Interfaces. When creating an instance (inside of a C++/CLR class) of a object through the COM interface, i pass in (void**)(&pr...
I'm sure this is a pretty straight forward question. I'm writing a small windows forms app using C++/CLI. When the form initializes, I start a thread that will process some code. When the code in the thread is executed, I want the thread to somehow update the text in a statusbar in the bottom of the window. So I was thinking something li...
I have a small memory leak in my code regarding Strings in CLI/C++. I've tried to fix the leak by deleting my unsigned char array, but when I do, I get a Memory Access Violation.
I assume this is because the System::String is a ref type, and because of that, the memory is associated with both 'testString' and 'uch' in the code below....