Reputation: 21898
Here's a very simple IDL interface that we've used successfully under VS2008 (arguments list shortened for brevity):
interface Mailer
{
string findNode( [in] string requestedNode );
unsigned short addMessage( [in] string msg, [in] unsigned short kind );
};
We're migrating the solution to VS2010 SP1. Now we have the following build error:
M.idl(3): error MIDL2025: syntax error : expecting a type specification near "string"
This always worked like a charm using VS2008 SP1
Note that I already replaced in
by [in]
. While scratching my head, I discovered that MIDL 2010 also dislikes in
but don't say anything about [in]
.
Note that unsigned short
is accepted (as observed by inverting the 2 methods of the interface).
How come? How can I make MIDL understand string
again ?
TIA.
Upvotes: 1
Views: 882
Reputation: 21898
It appears that the IDL file, although present in the project, isn't used at all. VS2008 silently ignored it (as it would do for an unreferenced .h file). For some reason, VS2010 tries to compile it even if it's not referenced anywhere else. And since the contents is totally buggy (string is indeed not a native IDL type but an attribute as best), I now have errors.
Solution: Exclude file from project!
Upvotes: 0
Reputation: 4505
For exposing from C# ,this:
interface Mailer
{
[return, MarshalAs(UnmanagedType.BStr)]
string findNode( [In, MarshalAs(UnmanagedType.BStr)] string requestedNode );
unsigned short addMessage( [In, MarshalAs(UnmanagedType.BStr)] string msg, [in] unsigned short kind );
};
I saw that you possibly mean exposing it from C++:
interface Mailer
{
HRESULT findNode( [out, retval] BSTR* result, [in] BSTR requestedNode );
HRESULT addMessage( [out, retval] unsigned short* result, [in] BSTR msg, [in] unsigned short kind );
};
Upvotes: 0