Explicit Conversion from Object to Reflection.AssemblyCompanyAttribute?

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
 
J

Jay B. Harlow [MVP - Outlook]

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
|
|
 
C

Carl Fenley

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top