.NET Framework Developer Center > .NET Framework Forums > Windows Presentation Foundation (WPF) > Getting at information entered in Assembly Information dialog

Answered Getting at information entered in Assembly Information dialog

  • Wednesday, October 08, 2008 11:36 PM
     
     
    In the Properties for a given WPF application (C#), one can enter the Title, Description, Company, Product, etc. in the Assembly Information dialog (Properties --> Application --> "Assembly Information..." ).

    ...but how can I read it at runtime?

    there doesn't seem to be a straightforward way to get at that information, unless I'm missing something.

    thanks!
    evan k. stone / sr. ux developer / dragnet solutions, inc.
    • Edited by Evan Stone Wednesday, October 08, 2008 11:37 PM
    •  

Answers

  • Wednesday, October 08, 2008 11:58 PM
     
     Answered
    anything you enter inside Assemblyinformation dialog sits in the AssemblyInfo.cs

    You can access these values using Assembly.GetExecutingAssembly.GetCustomAttributes(true/false);

    If you print the types of attributes returned, you can see something like shown below.

    System.Windows.ThemeInfoAttribute
    System.Diagnostics.DebuggableAttribute
    System.Runtime.CompilerServices.CompilationRelaxationsAttribute
    System.Runtime.InteropServices.ComVisibleAttribute
    System.Reflection.AssemblyFileVersionAttribute
    System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
    System.Reflection.AssemblyTitleAttribute
    System.Reflection.AssemblyDescriptionAttribute
    System.Reflection.AssemblyConfigurationAttribute
    System.Reflection.AssemblyCompanyAttribute
    System.Reflection.AssemblyProductAttribute
    System.Reflection.AssemblyCopyrightAttribute
    System.Reflection.AssemblyTrademarkAttribute


    So if you want to access the Description entered in the Assembly, you can do something like this.


        foreach (object o in Assembly.GetExecutingAssembly().GetCustomAttributes(true))
                {
                    if (o is AssemblyDescriptionAttribute) Debug.WriteLine((o as AssemblyDescriptionAttribute).Description);
                }

    That is just an example.

    Hope this helps.
    • Proposed As Answer by KrishnaBhargava Wednesday, October 08, 2008 11:59 PM
    • Marked As Answer by Evan Stone Thursday, October 09, 2008 12:09 AM
    •  

All Replies

  • Wednesday, October 08, 2008 11:58 PM
     
     Answered
    anything you enter inside Assemblyinformation dialog sits in the AssemblyInfo.cs

    You can access these values using Assembly.GetExecutingAssembly.GetCustomAttributes(true/false);

    If you print the types of attributes returned, you can see something like shown below.

    System.Windows.ThemeInfoAttribute
    System.Diagnostics.DebuggableAttribute
    System.Runtime.CompilerServices.CompilationRelaxationsAttribute
    System.Runtime.InteropServices.ComVisibleAttribute
    System.Reflection.AssemblyFileVersionAttribute
    System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
    System.Reflection.AssemblyTitleAttribute
    System.Reflection.AssemblyDescriptionAttribute
    System.Reflection.AssemblyConfigurationAttribute
    System.Reflection.AssemblyCompanyAttribute
    System.Reflection.AssemblyProductAttribute
    System.Reflection.AssemblyCopyrightAttribute
    System.Reflection.AssemblyTrademarkAttribute


    So if you want to access the Description entered in the Assembly, you can do something like this.


        foreach (object o in Assembly.GetExecutingAssembly().GetCustomAttributes(true))
                {
                    if (o is AssemblyDescriptionAttribute) Debug.WriteLine((o as AssemblyDescriptionAttribute).Description);
                }

    That is just an example.

    Hope this helps.
    • Proposed As Answer by KrishnaBhargava Wednesday, October 08, 2008 11:59 PM
    • Marked As Answer by Evan Stone Thursday, October 09, 2008 12:09 AM
    •  
  • Thursday, October 09, 2008 12:10 AM
     
     
    Thanks! I've implemented it already and it works perfectly!
    evan k. stone / sr. ux developer / dragnet solutions, inc.