views:

106

answers:

1

In C#, you can decorate function return values with attributes, as follows:

[return: MarshalAs(UnmanagedType.IUnknown)]
object LoadStuff();

My question is, how can I do this in C++/CLI? I have this:

[return: MarshalAs(UnmanagedType::IUnknown)]
Object^ LoadStuff();

but the compiler is erroring with 'return' : unknown attribute qualifier.

Is there an alternate syntax which I haven't been able to find?

+1  A: 

Use returnvalue instead of return

[returnvalue: MarshalAs(UnmanagedType::IUknown)]

The full list of attribute targets is available in section 28.2 of the C++/CLI spec (PDF)

JaredPar