S
Saad
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
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