Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

PreserveSig in VS 2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
racerX - 01 Mar 2007 22:03 GMT
I have been trying to migrate a VS 2003 project (dll) to VS 2005. I currently
use PreserveSig attribute on all COM visible properties and functions. When
compiling against the 1.1 framework all is well, but against the 2.0
framework I get “fatal error C1093: API call 'DefineCustomAttribute' failed
'0x801311c0' “. I discovered that by removing the PreserveSig attribute on
property definitions, the project compiles, but now my properties are
converted and exposed to COM in the HRESULT format (not desired). Any ideas?

Thanks,
Chris
Jeffrey Tan[MSFT] - 02 Mar 2007 12:41 GMT
Hi Chris,

I will perform some research on this issue and get back to you ASAP. 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.
Jeffrey Tan[MSFT] - 05 Mar 2007 04:43 GMT
Hi Chris,

Sorry for letting you wait.

Can you tell me why don't want the return type to be HRESULT in the IDL?
What exactly do these definitions look like in C# managed code?  Do you
return something other than int/uint?

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.
racerX - 06 Mar 2007 00:24 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.