Read Assembly's Guid into const

Emirates Angels 66 Reputation points
2021-12-16T17:10:43.273+00:00

Hi,

I have below Guid which is placed inside the AssemblyInfo.cs

[assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]

How can I read it back inside my App.xaml.cs as const like this:

internal const string AppOneID = [Guid Value Comes Here];

Thanks,
Jassim

Developer technologies | .NET | Xamarin
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2021-12-16T17:18:51.497+00:00

    Try this code:

    var ca = (GuidAttribute)Attribute.GetCustomAttribute( Assembly.GetEntryAssembly( ), typeof( GuidAttribute ) );
    string guid = ca.Value;
    

    and this:

    internal readonly string AppOneID = ( (GuidAttribute)Attribute.GetCustomAttribute( Assembly.GetEntryAssembly( ), typeof( GuidAttribute ) ) ).Value;
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.