Explicit Conversion from Object to Reflection.AssemblyCompanyAttribute?

  • Thread starter Thread starter Carl Fenley
  • Start date Start date
C

Carl Fenley

Help a newbie out. I cannot seem to explicitly convert an Object to a
Reflection.AssemblyCompanyAttribute 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.Reflection.AssemblyCompanyAttribute'.

Here is the code:

Public ReadOnly Property Company() As String Implements
IAssemblyInfo.Company
Get
Dim attrCompany As SR.AssemblyCompanyAttribute
'*** The following line produces the conversion error ***
attrCompany =
Me._assemblyInfo.GetCustomAttributes(GetType(SR.AssemblyCompanyAttribute),
False)(0)
Return attrCompany.Company.ToString

End Get
End Property

Any help is greatly appreciated.

carl
 
Carl,
Try the following:

attrCompany = DirectCast( _
Me._assemblyInfo.GetCustomAttributes( _
GetType(SR.AssemblyCompanyAttribute), False)(0), _
SR.AssemblyCompanyAttribute)

Hope this helps
jay

| Help a newbie out. I cannot seem to explicitly convert an Object to a
| Reflection.AssemblyCompanyAttribute 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.Reflection.AssemblyCompanyAttribute'.
|
| Here is the code:
|
| Public ReadOnly Property Company() As String Implements
| IAssemblyInfo.Company
| Get
| Dim attrCompany As SR.AssemblyCompanyAttribute
| '*** The following line produces the conversion error ***
| attrCompany =
| Me._assemblyInfo.GetCustomAttributes(GetType(SR.AssemblyCompanyAttribute),
| False)(0)
| Return attrCompany.Company.ToString
|
| End Get
| End Property
|
| Any help is greatly appreciated.
|
| carl
|
|
 
Jay B. Harlow said:
Carl,
Try the following:

attrCompany = DirectCast( _
Me._assemblyInfo.GetCustomAttributes( _
GetType(SR.AssemblyCompanyAttribute), False)(0), _
SR.AssemblyCompanyAttribute)

Hope this helps
jay

Thanks! That worked like a charm.

carl
 
Back
Top