Hi Jeffrey,
> Can you tell me why don't want the return type to be HRESULT in the IDL?
We currently have umanaged clients that are using our library with preserved
signatures.
> What exactly do these definitions look like in C# managed code? Do you
> return something other than int/uint?
I am not sure what your question is here. I am writing in managed C++ with
an interface definition that looks something like:
[Guid("someGUIDhere")]
public __gc __interface IMyList :
public IList,
public ICollection
{
public:
[PreserveSig] __property int get_Count();
[PreserveSig] __property bool get_IsFixedSize();
[PreserveSig] __property bool get_IsReadOnly();
[PreserveSig] __property Object * get_Item (int index);
[PreserveSig] __property void set_Item (int index, Object *);
[PreserveSig] int Add(Object * value);
[PreserveSig] void Clear();
[PreserveSig] bool Contains(Object * value);
[PreserveSig] int IndexOf(Object * value);
[PreserveSig] void Insert (int index, Object *value);
[PreserveSig] void Remove(Object * value);
[PreserveSig] void RemoveAt (int index);
};
So I am passing ints, bools and pointers. The PreserveSig works as expected
in VS 2003, C# clients see the properties as C# properties, etc.
Thanks,
Chris
> Hi Chris,
>
[quoted text clipped - 27 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT] - 06 Mar 2007 10:04 GMT
Hi Chris,
Thanks for your feedback!
It seems that you are using some old style CLR syntax in the new VC++2005.
This may be a side area.
Is it possible for you to send a little sample project to help me reproduce
this problem locally? Then I may perform some deep troubleshooting over it.
You may send the reproduce project to: jetan@online.microsoft.com(remove
"online.")
Thanks very much!
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT] - 07 Mar 2007 07:05 GMT
Hi Chris,
Additionally, it seems that your old-syntax CLR marks PreserveSig on
properties.
I have also discussed this issue with one COM interop expert internally.
Based on the MSDN document below, PreserveSigAttribute is valid on methods
only(AttributeTargets.Method):
"PreserveSigAttribute Class"
http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.pres
ervesigattribute.aspx
So it is not supported for properties. In C# if you try and apply it to a
property declaration you will get a compiler error that is worded much
better(in both VS.net2003 and VS2005):
"Attribute 'PreserveSig' is not valid on this declaration type. It is valid
on 'method' declarations only."
Since the PreserveSigAttribute is not supported for properties, we are not
sure why the VC compiler allowed yoru code to compile in VS.NET 2003.
I would recommend you to provide a little sample project to give us a local
reproduce, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.