Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Exporting Managed Code as Flat API to Unmanaged World

Reply
 
Old 09-26-2008   #1 (permalink)
Saad


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46