469,356 Members | 1,999 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Programatically getting my AssemblyVersion

How does one get the AssemblyVersion of the currently excuting
assembly? At first glance, it would appear that this would give you
the AsseblyName which will give you the version:

string appName =
AppDomain.CurrentDomain.SetupInformation.Applicati onName;
AssemblyName assemblyName = AssemblyName.GetAssemblyName(appName);

But the appname is <name>.vshost.exe. Is there any way to find out the
name of the assembly minus the vshost?

Feb 21 '06 #1
3 38014
The answer:

string appName = Assembly.GetAssembly(this.GetType()).Location;
AssemblyName assemblyName = AssemblyName.GetAssemblyName(appName);
return assemblyName.Version.ToString();

Feb 21 '06 #2
>string appName = Assembly.GetAssembly(this.GetType()).Location;
AssemblyName assemblyName = AssemblyName.GetAssemblyName(appName);
return assemblyName.Version.ToString();


Or just

return this.GetType().Assembly.GetName().Version.ToString ();
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 21 '06 #3
Hi,

"herc" <ca******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
The answer:

string appName = Assembly.GetAssembly(this.GetType()).Location;
AssemblyName assemblyName = AssemblyName.GetAssemblyName(appName);
return assemblyName.Version.ToString();


A shorter way:

Assembly.GetExecutingAssembly().GetName.Version.To String()

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mark | last post: by
2 posts views Thread by Mark | last post: by
4 posts views Thread by Matthew Smith | last post: by
7 posts views Thread by Michael Maes | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.