System.Reflection.Assembly.GetExecutingAssembly

G

Greg Bell

Hi why does first bit work and 2nd doesn't:

1.
Dim m_Trademark As SR.AssemblyTrademarkAttribute

m_Trademark =
m_AssInfo.GetCustomAttributes(GetType(SR.AssemblyTrademarkAttribute),
False)(0)

2.

Dim m_Version As SR.AssemblyVersionAttribute

Try

m_Version =
m_AssInfo.GetCustomAttributes(GetType(SR.AssemblyVersionAttribute),
False)(0)

Return m_Version.Version.ToString

Catch Ex As Exception

MsgBox(Ex.ToString)

End Try



The error says that IndexOutOfRangeException

but the AssemblyInfo.vb has:

<Assembly: AssemblyTitle("Test")>

<Assembly: AssemblyDescription("Test System")>

<Assembly: AssemblyCompany("Bell")>

<Assembly: AssemblyProduct("DotNetProject")>

<Assembly: AssemblyCopyright("Copyright © 2005 . All rights reserved.")>

<Assembly: CLSCompliant(True)>

<Assembly: AssemblyVersion("1.5.*")>



Greg
 
M

Mattias Sjögren

Greg,
Hi why does first bit work and 2nd doesn't:

AssemblyVersionAttribute is special. The attribute is removed since
the version becomes part of the assembly name. You get it with
m_AssInfo.GetName().Version.



Mattias
 
G

Greg Bell

Thanks Mattias,


Mattias Sjögren said:
Greg,


AssemblyVersionAttribute is special. The attribute is removed since
the version becomes part of the assembly name. You get it with
m_AssInfo.GetName().Version.



Mattias
 

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