![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Exporting Managed Code as Flat API to Unmanaged World Hi, I have a MC++dll, whose functions i want to use in unmanaged c++. I read that one of the ways to use the managed functions in unmanaged world is by exposing the managed api as flat api. I tried that and with simple data types it worked. But now i need to export a function which needs to take a gc struct as parameter, and then fill some values in it, and then the unmanaged c++ will use that info. Here's what i did //My gc struct [StructLayout(LayoutKind::Sequential,CharSet=CharSet::Ansi)] public __gc struct STLayout { public: [MarshalAs(UnmanagedType::LPTStr)] String* ID; }; //End Now i'm trying to export this through a funtion like this:- __declspec(dllexport) int ExportL([MarshalAs(UnmanagedType::Struct)]STLayout*& Layout) And when i compile this dll. i'm getting the following error:- error C3395: __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention Now im stuck.... what i dont understand is that 1) why isn't the MarshalAs attribute working here..... 2) What is the preferred way of exporting the managed types to c+ +....other than the COM interop, mixed-mode solutions...... Any other ideas... Thanks in advance... Saad. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Problem getting exception info from unmanaged C++ | .NET General | |||
| Dispose Unmanaged resources | .NET General | |||
| Implementing Unmanaged Interface in C# | .NET General | |||
| Slow performance initializing PowerShell from managed code | PowerShell | |||