Specifically I want to be able to determine at runtime when portable class library code is running on Silverlight, WinRT, or .NET
My best idea right now is:
typeof(object).Assembly.GetCustomAttribute<AssemblyProductAttribute>().Product
On .NET it returns "Microsoft® .NET Framework" and on Silverlight it returns "Microsoft® Silverlight" but I'm not sure if it distinguishes itself on WinRT as I'm not developing with Windows 8 at the moment.
So I'd like to know if that works or any better ideas.
Answer: 1
While there are usually very few good reasons for it, here's a class that does so:
I use it as part of logic to determine IsInDesignTime for a PCL.
by : Oren Novotnyhttp://stackoverflow.com/users/738188
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog