472,122 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 38116
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 leo001 | last post: by

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.