Lets get the basic stuff out of the way first:
Code:
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
The within your code to go from managed to unmanaged pointers, you'll need to pin the pointers first (stops the GC from relocating while they are being used in unmanaged code) e.g.:
Code:
int Old_GetTagData (int TagID, unsigned char *DestBuffer);
...
   Int32 TestTag::GetTagData (Int32 TagNum, [Out] Byte TagData[])
      {
      Byte __pin *bp = &(TagData[0]);
      Int32 rc;

      rc = Old_GetTagData (TagNum, bp);
      return (rc);
      }
In this example TestTag::GetTagData is a new class I created in MC++ to talk to C# and OldGetTagData() was from an unmodifed existing C DLL.

In your case, you might not need to create a wrapper, you need only make sure the parameter type can be translated to the CLR types (either by default of explicitly by adding attributes).

Compile your C++ with the /clr switch so that it may run fully under .NET (In my case I still had to use the existing native C DLL). Interfacing Managed C++ with C# is the easiest. In the above example I used the [Out] attribute because when (If ?) we port this function to pure C#, the "Out" attribute will be required as the Byte array would be passed by value otherwise.

Read the "managedextensionsspec.doc" for a good understanding of MC++.

For ADSOFT:
Quote Originally Posted by adsoft
First of all let me get this right. Your saying that you where able to recompile and existing MFC project with the /clr option and it generated byte code the would execute on the .NET RUN-TIME????
Yes, "It Just Works" (thats Microsoft's name, not mine).