none
CLR to STL Marshaling RRS feed

  • Question

  • Hi, everybody! I'm working with .NET Framework 1.1 C#. The problem is that I need to pass parameter to unmanaged dll, but in unmanaged code it's described as: typedef std::list< MyClass> MyClassList; what type should i declare in managed code to pass this parameter correctly? I've searched a lot of forums and artiocles but found nothing, except simple types such as: void* - System.IntPtr unsigned char - System.Byte short - System.Int16 char* - System.String ... and so on. Thank you!
    Monday, July 21, 2008 10:46 AM

Answers

  • Being stuck at .NET 1.1, you'll have to use an obsolete C++ dialect, it might be tough to find a good example.  Start by googling "C++/CLI wrapper class".
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, July 25, 2008 11:10 AM
    Monday, July 21, 2008 11:38 AM
    Moderator

All replies

  • It's not possible to do this directly, your C# code can't create an instance of an unmanaged class type.  You'll need to write a managed class wrapper in the MC++ syntax.  That wrapper can use the new operator to create the std::list object.
    Hans Passant.
    Monday, July 21, 2008 11:22 AM
    Moderator
  • Thank you. Are there any useful links or articles with examples of such wrapper classes?
    Monday, July 21, 2008 11:31 AM
  • Being stuck at .NET 1.1, you'll have to use an obsolete C++ dialect, it might be tough to find a good example.  Start by googling "C++/CLI wrapper class".
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, July 25, 2008 11:10 AM
    Monday, July 21, 2008 11:38 AM
    Moderator