Problem with DLLIMPORT RRS feed

  • Question

  • I am trying to access a method in a third part DLL

    bool NNSMCAPI::Client::initialize(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)

    I am not familiar with these types?

    I've tried "UnmanagedType.BStr" with the most luck, however, I now get an AccessViolationException.

    Any help would be much appreciated.

    [DllImport(DLLAPI, CharSet = CharSet.Unicode, EntryPoint = @"entrypoint")]
            public static extern bool Initialize([MarshalAs(UnmanagedType.BStr)]string transportDLL);


    Monday, September 22, 2008 6:09 PM


  • You cannot P/Invoke this function.  The function itself is a C++ member method, the arguments are C++ objects as well.  You'll need to write a managed wrapper using the C++/CLI syntax.  You'll need the help of a skilled C++ programmer that's familiar with the STL and knows a bit of C++/CLI syntax.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, September 29, 2008 6:09 AM
    Monday, September 22, 2008 8:35 PM