Explicit Conversion from Object to Reflection.AssemblyCompanyAttribute?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Fenley

    #1

    Explicit Conversion from Object to Reflection.AssemblyCompanyAttribute?

    Help a newbie out. I cannot seem to explicitly convert an Object to a
    Reflection.Asse mblyCompanyAttr ibute type using DirectCast(). Turning Option
    Strict "Off" is not an option.

    Here is the Error:

    Option Strict On disallows implicit conversions from 'System.Object' to
    'System.Reflect ion.AssemblyCom panyAttribute'.

    Here is the code:

    Public ReadOnly Property Company() As String Implements
    IAssemblyInfo.C ompany
    Get
    Dim attrCompany As SR.AssemblyComp anyAttribute
    '*** The following line produces the conversion error ***
    attrCompany =
    Me._assemblyInf o.GetCustomAttr ibutes(GetType( SR.AssemblyComp anyAttribute),
    False)(0)
    Return attrCompany.Com pany.ToString

    End Get
    End Property

    Any help is greatly appreciated.

    carl


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Explicit Conversion from Object to Reflection.Asse mblyCompanyAttr ibute?

    Carl,
    Try the following:

    attrCompany = DirectCast( _
    Me._assemblyInf o.GetCustomAttr ibutes( _
    GetType(SR.Asse mblyCompanyAttr ibute), False)(0), _
    SR.AssemblyComp anyAttribute)

    Hope this helps
    jay

    "Carl Fenley" <clfenley-X-@-X-wcpci.com> wrote in message
    news:OFdwVJEeFH A.2736@TK2MSFTN GP12.phx.gbl...
    | Help a newbie out. I cannot seem to explicitly convert an Object to a
    | Reflection.Asse mblyCompanyAttr ibute type using DirectCast(). Turning
    Option
    | Strict "Off" is not an option.
    |
    | Here is the Error:
    |
    | Option Strict On disallows implicit conversions from 'System.Object' to
    | 'System.Reflect ion.AssemblyCom panyAttribute'.
    |
    | Here is the code:
    |
    | Public ReadOnly Property Company() As String Implements
    | IAssemblyInfo.C ompany
    | Get
    | Dim attrCompany As SR.AssemblyComp anyAttribute
    | '*** The following line produces the conversion error ***
    | attrCompany =
    | Me._assemblyInf o.GetCustomAttr ibutes(GetType( SR.AssemblyComp anyAttribute),
    | False)(0)
    | Return attrCompany.Com pany.ToString
    |
    | End Get
    | End Property
    |
    | Any help is greatly appreciated.
    |
    | carl
    |
    |


    Comment

    • Carl Fenley

      #3
      Re: Explicit Conversion from Object to Reflection.Asse mblyCompanyAttr ibute?

      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message
      news:eJNxukGeFH A.3932@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Carl,
      > Try the following:
      >
      > attrCompany = DirectCast( _
      > Me._assemblyInf o.GetCustomAttr ibutes( _
      > GetType(SR.Asse mblyCompanyAttr ibute), False)(0), _
      > SR.AssemblyComp anyAttribute)
      >
      > Hope this helps
      > jay[/color]

      Thanks! That worked like a charm.

      carl


      Comment

      Working...