473,770 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get assembly file info?

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

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim apptitle As System.Reflecti on.AssemblyTitl eAttribute

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

Error is:

An unhandled exception of type 'System.NullRef erenceException ' 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.Reflecti on.AssemblyTitl eAttribute

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 3520
Brett wrote:
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim apptitle As System.Reflecti on.AssemblyTitl eAttribute

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


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

Try this:

Imports System.Reflecti on
[...]

Dim objTitle As AssemblyTitleAt tribute
objTitle = DirectCast( _
AssemblyTitleAt tribute.GetCust omAttribute( _
Me.GetType.Asse mbly, GetType(Assembl yTitleAttribute )), _
AssemblyTitleAt tribute)
Me.Label1.Text = objTitle.Title

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

It then uses the shared GetCustomAttrib ute member of the
AssemblyTitleAt tribute class to point the object at the
AssemblyTitleAt tribute object that is built into your project. It uses
DirectCast to cast this from the generic Object to the specific object type
being used (AssemblyTitleA ttribute).

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
11509
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 ASP.NET. In brief I will explain: I want to create one Application domain, and call one assembly in that created application domain, and excute some methods/functions of that calling assembly and unload the application domain. All these things...
5
4992
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 in assemblyinfo.cs? I have the following code after using System.Runtime.CompilerServices;: string s; I keep getting the following error:
11
3141
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 useful utils that more pages on that server can use. As an example, I have created a Page Counter class that opens an Access .mdb file, counts the current entries for that page, and adds a new entry with some information regarding the current...
4
1602
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 application, all pages are JIT compiled on request), and I want link a assembly with the “src” attribute, like <%@ Assembly Src=”/MyWebApplication/Common/MyAssemblyClass.cs” %>
10
3482
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 somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
5
1919
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 (or higher). I place the vb.net exe on the workstation. In vb6 I used to have to run setup if there were any fancy controls on the vb6 exe. So, in order to correctly deploy a vb.net exe what all is involved besides having .Net Framework on each...
2
568
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 this application, just worked with that some days. >> Today, I decided to open the project in VS.2005 and everything seemed >> to be fine, all opened and everything was migrated. I have been >> working on improvements on it this day. >>
1
10806
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. Today, I wanted to access the home page of the application again with a browser. But instead of the proper page, I just got an ugly message: Server Error in '/' Application.
5
12098
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 two versions. The assembly is the file, isn't it?
0
1326
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 "X:\Blablabla\AppA\bin\Debug") and an callee application named "GEMOfficeTSW" (in a directory like "X:\Gagaga\AppB\bin\Debug"). The latter saves settings in its GEMOfficeTSW.exe.config and user.config in C:\Documents and Settings\username\Local Settings\Application
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.