WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.212' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714556863.1812500953674316406250', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
<\/a>It’s always a good thing to provide information to the users of your application. One thing which may seem trivial is the version number. In fact it’s a really important information because with it the customers can send you a feedback with enough information to know in which version you have to fix the bug.<\/p>\n In ConsoTracker, the app I build on Windows Phone<\/a>, I forgot to provide it and users ask met to provide it ! <\/p>\n In this post you’ll discover that the classic .Net way does not work and how to retrieve it from your code. Before I give you the code, be aware that the version number you set in your assembly is not read by the MarketPlace<\/strong>. In fact, you provide the information to it in the app submission process. <\/p>\n You do so have to update it in your code as you give the correct version to the market place.<\/p>\n In .Net you can retrieve the version number of an application from it’s regarding assembly object instance. That’s too bad because it would have been clean way to retrieve it. Instead you have to read the assembly name and deduce the version number from it<\/strong>. <\/p>\n Here is the helper I use in my application: var assembly = Assembly.GetExecutingAssembly().FullName; version = new Version(fullVersionNumber);<\/p>\n return version; Be sure that the version number are synched if you put this code in another assembly<\/strong>. You can do this by sharing a file containing the AssemblyVersion attributes using ‘Add as link’ instead of adding a copy of the file.<\/p>\n Also, as it may represent a performance cost, I recommend you to to call it only once trough a static constructor.<\/p>\n","protected":false},"excerpt":{"rendered":" It’s always a good thing to provide information to the users of your application. One thing which may seem trivial is the version number. In fact it’s a really important information because with it the…<\/p>\n","protected":false},"author":3,"featured_media":799,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/787"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=787"}],"version-history":[{"count":15,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/787\/revisions"}],"predecessor-version":[{"id":805,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/787\/revisions\/805"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media\/799"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=787"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\n<\/strong><\/p>\nWarning !<\/h3>\n
How to do it ?<\/h3>\n
\n[csharp]System.Reflection.Assembly.GetExecutingAssembly().GetName().Version[\/csharp]
\nIf you try it on a Windows Phone, you’ll discover that calling the property throw an exception. Also, as pointed out by Thomas<\/a> in a tweet<\/a>, it’s security critical which restricts it to internal use by the .NET Framework for Silverlight class library<\/a>.<\/p>\n
\n[csharp]\/\/\/ <summary>
\n\/\/\/ Retrieve the current version of the executing assembly.
\n\/\/\/ This is the one in the AssemblyVersion attribute.
\n\/\/\/ <\/summary>
\n\/\/\/ <returns><\/returns>
\npublic static Version GetCurrentVersion()
\n{
\n Version version;<\/p>\n
\n var fullVersionNumber = assembly.Split(‘=’)[1].Split(‘,’)[0];<\/p>\n
\n}
\n[\/csharp]<\/p>\n