Click here to Skip to main content
15,914,608 members
Home / Discussions / C#
   

C#

 
AnswerRe: VS 2017 c# Getting Current Version number Pin
OriginalGriff5-Mar-19 20:04
mveOriginalGriff5-Mar-19 20:04 
These are the methods I use:
/// <summary>
/// Gets the assembly Title
/// </summary>
public string AssemblyTitle
    {
    get
        {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
        if (attributes.Length > 0)
            {
            AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
            if (titleAttribute.Title != "")
                {
                return titleAttribute.Title;
                }
            }
        return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
        }
    }
/// <summary>
/// Gets the assembly Version
/// </summary>
public string AssemblyVersion
    {
    get
        {
        return Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }
    }
/// <summary>
/// Gets the assembly Description
/// </summary>
public string AssemblyDescription
    {
    get
        {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
        if (attributes.Length == 0)
            {
            return "";
            }
        return ((AssemblyDescriptionAttribute)attributes[0]).Description;
        }
    }
/// <summary>
/// Gets the assembly Product
/// </summary>
public string AssemblyProduct
    {
    get
        {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
        if (attributes.Length == 0)
            {
            return "";
            }
        return ((AssemblyProductAttribute)attributes[0]).Product;
        }
    }
/// <summary>
/// Gets the assembly copyright notice
/// </summary>
public string AssemblyCopyright
    {
    get
        {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
        if (attributes.Length == 0)
            {
            return "";
            }
        return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
        }
    }
/// <summary>
/// Gets the assembly Company
/// </summary>
public string AssemblyCompany
    {
    get
        {
        object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
        if (attributes.Length == 0)
            {
            return "";
            }
        return ((AssemblyCompanyAttribute)attributes[0]).Company;
        }
    }
Note that is the Executing Assembly it fetches data for - i.e. the assembly that that specific code is compiled into. If that is a DLL used by the app - i.e. a code library - it will fetch the data for the DLL, not the original EXE that called it. For the original EXE assembly data, replace GetExecutingAssembly with GetEntryAssembly
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: VS 2017 c# Getting Current Version number Pin
ormonds6-Mar-19 17:54
ormonds6-Mar-19 17:54 
GeneralRe: VS 2017 c# Getting Current Version number Pin
OriginalGriff6-Mar-19 22:11
mveOriginalGriff6-Mar-19 22:11 
GeneralRe: VS 2017 c# Getting Current Version number Pin
ormonds7-Mar-19 0:33
ormonds7-Mar-19 0:33 
QuestionBest Architecture dotnet app Pin
Member 132039775-Mar-19 5:38
Member 132039775-Mar-19 5:38 
AnswerRe: Best Architecture dotnet app Pin
Gerry Schmitz5-Mar-19 7:57
mveGerry Schmitz5-Mar-19 7:57 
RantRe: Best Architecture dotnet app Pin
Bohdan Stupak5-Mar-19 22:25
professionalBohdan Stupak5-Mar-19 22:25 
GeneralRe: Best Architecture dotnet app Pin
Member 132039775-Mar-19 23:42
Member 132039775-Mar-19 23:42 
GeneralRe: Best Architecture dotnet app Pin
Bohdan Stupak6-Mar-19 1:04
professionalBohdan Stupak6-Mar-19 1:04 
QuestionUsing the Black Box method in C# Pin
Brian_TheLion4-Mar-19 18:57
Brian_TheLion4-Mar-19 18:57 
AnswerRe: Using the Black Box method in C# Pin
OriginalGriff4-Mar-19 20:00
mveOriginalGriff4-Mar-19 20:00 
GeneralRe: Using the Black Box method in C# Pin
Brian_TheLion4-Mar-19 23:20
Brian_TheLion4-Mar-19 23:20 
GeneralRe: Using the Black Box method in C# Pin
OriginalGriff5-Mar-19 0:04
mveOriginalGriff5-Mar-19 0:04 
GeneralRe: Using the Black Box method in C# Pin
Brian_TheLion5-Mar-19 11:47
Brian_TheLion5-Mar-19 11:47 
AnswerRe: Using the Black Box method in C# Pin
Gerry Schmitz5-Mar-19 8:10
mveGerry Schmitz5-Mar-19 8:10 
GeneralRe: Using the Black Box method in C# Pin
Brian_TheLion5-Mar-19 11:45
Brian_TheLion5-Mar-19 11:45 
GeneralRe: Using the Black Box method in C# Pin
Gerry Schmitz6-Mar-19 4:13
mveGerry Schmitz6-Mar-19 4:13 
GeneralRe: Using the Black Box method in C# Pin
Brian_TheLion6-Mar-19 11:32
Brian_TheLion6-Mar-19 11:32 
Questionc#, winforms, moving the app to another monitor and updating the screen device name Pin
jkirkerx4-Mar-19 7:01
professionaljkirkerx4-Mar-19 7:01 
AnswerRe: c#, winforms, moving the app to another monitor and updating the screen device name Pin
jkirkerx4-Mar-19 7:15
professionaljkirkerx4-Mar-19 7:15 
GeneralHow to center a progress bar dialog across multiple monitors Pin
jkirkerx4-Mar-19 9:44
professionaljkirkerx4-Mar-19 9:44 
AnswerRe: c#, winforms, moving the app to another monitor and updating the screen device name Pin
Gerry Schmitz5-Mar-19 8:24
mveGerry Schmitz5-Mar-19 8:24 
GeneralRe: c#, winforms, moving the app to another monitor and updating the screen device name Pin
jkirkerx5-Mar-19 10:37
professionaljkirkerx5-Mar-19 10:37 
QuestionPlease tell me what is wrong with this simple C# program Pin
Brian_TheLion3-Mar-19 23:20
Brian_TheLion3-Mar-19 23:20 
AnswerRe: Please tell me what is wrong with this simple C# program Pin
OriginalGriff3-Mar-19 23:46
mveOriginalGriff3-Mar-19 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.