473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to get assembly file info?

Using Reflector,
URL:http://www.aisto.com/roeder/dotnet/D...=Reflector.zip, I
see in System.Reflection there is a class called AssemblyTitleAttribute. It
has a read only property named Title. I do the following to get my
application name.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim apptitle As System.Reflection.AssemblyTitleAttribute

Me.Label1.Text = apptitle.Title.ToString
End Sub

Error is:

An unhandled exception of type 'System.NullReferenceException' occurred in
MainForm.exe

Additional information: Object reference not set to an instance of an
object.
However, if I try to declare an instance:
Dim apptitle As New System.Reflection.AssemblyTitleAttribute

I get this error under apptitle:
Argument not specified for parameter 'title' of Public Sub New(Title As
String)

Can I use the above class to get the title? There's a work around available
to getting assembly file info but it requires a lot of code. I'd like to
understand what I have done wrong here though.

Thanks,
Brett
Nov 21 '05 #1
1 3507
Brett wrote:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim apptitle As System.Reflection.AssemblyTitleAttribute

Me.Label1.Text = apptitle.Title.ToString
End Sub
The problem here is that you declared an AssemblyTitleAttribute object, but
you haven't set it to anything, so you just have a pointer to Nothing.
Dim apptitle As New System.Reflection.AssemblyTitleAttribute


Here you're trying to create a brand new AssemblyTitleAttribute. That's not
going to help you, as it won't have your assembly's title stored within it.

Try this:

Imports System.Reflection
[...]

Dim objTitle As AssemblyTitleAttribute
objTitle = DirectCast( _
AssemblyTitleAttribute.GetCustomAttribute( _
Me.GetType.Assembly, GetType(AssemblyTitleAttribute)), _
AssemblyTitleAttribute)
Me.Label1.Text = objTitle.Title

This declares an AssemblyTitleAttribute object, as in your first piece of
code, which initially points to Nothing.

It then uses the shared GetCustomAttribute member of the
AssemblyTitleAttribute class to point the object at the
AssemblyTitleAttribute object that is built into your project. It uses
DirectCast to cast this from the generic Object to the specific object type
being used (AssemblyTitleAttribute).

Once this has been done you can just read the Title string from the object.

Hope that helps,

--

(O) e n o n e
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raveendra | last post by:
Hi! I am trying to create one new Application Domain and calling one Assembly in that created Application Domain. It is working fine with stand alone application. But I need to do the same with...
5
by: John | last post by:
Hello, I would like to create a global string variable in my assemblyinfo.cs file. This string will contain the value of my version info. Can anybody tell me how to create a global string value...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
4
by: DELESTRE Christophe | last post by:
I’m sorry to disturb you but I have a problem on .NET development, and I’m need some help to resolve it if it’s possible. I have an aspx page with src property (no dll for my web...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
5
by: Rich | last post by:
Hello, So I develop a vb.net exe on my (win2k) workstation. I have to deploy it to another workstation (actually several - all win2k). Each receiving workstation will have .Net Framework 1.1...
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
1
by: urs | last post by:
Two days ago, I built an ASP.NET 2.0 application and published it on a shared IIS 6 Web server. After publishing, and during the whole day, it worked fine. The server remained untouched since....
5
by: Laurence | last post by:
In VS.2005 using VB.NET There are two versions on every project, The Assembly Version and the File Version. Why are there two different versions? As far as I can tell, there is not need for...
0
by: Michael Kremser | last post by:
Hi NG! I have troubles with loading an application to its own app domain. I have two applications: An caller application named "OfficeTSWCallerDemo" (in a directory like...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.