c# - How can I get the executing assembly version? -
i trying executing assembly version in c# 3.0 using following code:
var assemblyfullname = assembly.getexecutingassembly().fullname; var version = assemblyfullname .split(',')[1].split('=')[1];
is there proper way of doing so?
two options... regardless of application type can invoke:
assembly.getexecutingassembly().getname().version
if windows forms application, can access via application if looking product version.
application.productversion
using getexecutingassembly
assembly reference not option. such, find useful create static helper class in projects may need reference underlying assembly or assembly version:
// sample assembly reference class exist in `core` project. public static class coreassembly { public static readonly assembly reference = typeof(coreassembly).assembly; public static readonly version version = reference.getname().version; }
then can cleanly reference coreassembly.version
in code required.
Comments
Post a Comment