Search

"Object must be the same type as the enum" exception calling CommandBars.Add from an add-in by MVP CarlosQ

Closed
as Fixed Help for as Fixed

3
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 462766
Opened: 6/1/2009 7:41:41 AM
Access Restriction: Public
1
Workaround(s)
2
User(s) can reproduce this bug
When you create an add-in with the wizard and make this call:

toolBar = commandBars.Add(Name:="My toolbar", Position:=Microsoft.VisualStudio.CommandBars.MsoBarPosition.msoBarTop, Temporary:=True)

you get the exception:

"Object must be the same type as the enum. The type passed in was 'Microsoft.VisualStudio.CommandBars.MsoBarPosition'; the enum type was 'Microsoft.VisualStudio.CommandBars.MsoBarPosition'."
Details (expand)
Product Language
English

Version

Visual Studio 2010 Beta 1
Operating System
Windows XP Professional
Operating System Language
English
Steps to Reproduce
With VS 2010 Beta 1, create a VB.NET add-in with the add-in wizard and add the code of the attached file.

Debug the add-in.
Actual Results
"Object must be the same type as the enum. The type passed in was 'Microsoft.VisualStudio.CommandBars.MsoBarPosition'; the enum type was 'Microsoft.VisualStudio.CommandBars.MsoBarPosition'."
Expected Results
No exception.

This problems seems to happen because the add-in wizard uses the Microsoft.VisualStudio.CommandBars reference with the "Embed Interop Types" property set to True, and the CommandBars.Add call performs some type checking. So, either don't perform the type checking, or make the wizard to set that property to False (which solves the problem).
TAP Code (if applicable)
VSIPISSUE
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
1 attachments
Connect.vb
Sign in to post a comment.
Posted by Microsoft on 6/2/2009 at 11:21 PM
Thanks for your feedback.

We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 10/23/2009 at 7:18 PM
Many thanks for reporting this issue. It will be fixed in .NET Framework 4.0 RC/RTM releases.

Thanks!
Ladi Prosek, CLR team