Plip's Weblog

Phil Winstanley - British .NET chap based in Lancashire. Enjoys tea and tech. Working for Microsoft.

February 2006 - Posts

Total Smoking ban UK Public Places


About bloody time!

http://news.bbc.co.uk/1/hi/uk_politics/4714992.stm


Posted: Feb 15 2006, 06:29 PM by Plip | with 13 comment(s)
Filed under:
Display the version of all assemblies in an ASP.NET application on a page
More often than not it's quite useful to know if a Web site is running the latest version of assemblies, especially if you have shared common code which is updated regularly.

NameVersion
App_Code.pacsdi-w1.0.0.42746
Ajax5.7.25.1
CustomProviders1.0.0.0

This snippet of code will print out a table of all (relevant - it excludes .NET assemblies or anything with no version) assembly versions to the page. (Yes the code is crude, I just like Olde Worlde Response.Write-esque code!)

    1         this.Controls.Add(new LiteralControl("<table border=1 width=50%><tr><td>Name</td><td>Version</td></tr>"));

    2         Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

    3 

    4         foreach (Assembly a in assemblies)

    5         {

    6             //Ignore the Framework Assembly's

    7             string ExcludedNames = ("SystemMicrosoft.JScriptVJSharpCodeProviderCppCodeProviderWebDev.WebHostmscorlib");

    8             if ((a.GetName().Name.ToString().IndexOf("System") < 0) && (a.GetName().Name.ToString().IndexOf("Microsoft") < 0) && (ExcludedNames.IndexOf(a.GetName().Name.ToString()) < 0) && (a.GetName().Version.ToString() != "0.0.0.0"))

    9             {

   10 

   11                 try

   12                 {

   13                     string Version = a.GetName().Version.ToString();

   14                     AssemblyInformationalVersionAttribute[] infoversion = (AssemblyInformationalVersionAttribute[])a.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);

   15                     if (infoversion.Length == 1)

   16                     {

   17                         Version += (" (" + infoversion[0].InformationalVersion.ToString() + ")");

   18                     }

   19                     LiteralControl lit = new LiteralControl();

   20                     lit.Text = "<tr><td>" + a.GetName().Name.ToString() + "</td><td>" + Version + "</td></tr>";

   21 

   22                     this.Controls.Add(lit);

   23                 }

   24                 catch

   25                 {

   26                 }

   27 

   28             }

   29         }

   30         this.Controls.Add(new LiteralControl("</table>"));


If you're using ASP.NET 2.0 this can produce some "odd" looking results because of the new compilation engine. One way to avoid these results is to use the aspnet_merge tool which ships with the Visual Studio 2005 Web Deployment Projects plugin for Visual Studio.
Posted: Feb 05 2006, 12:01 AM by Plip | with 2 comment(s)
Filed under:
Writing custom Build Tasks for VS.NET 2005
I've been playing around with creating my own Build Tasks for Visual Studio 2005 and more specifically Web Deployment Projects.

In the course of playing around I've written some tasks (which I'll share with you all very soon) that hook into the Red Gate Sql Compare and Sql Data Compare products to deploy all my local SQL Server Schema and Data changes to the Development/Staging server when I deploy my applications. I've in effect created a "ClickOnce" ASP.NET deployment, which is pretty damn cool.

Here's a quick snippet of the Build Tasks in my wdproj file.

   66   <Target Name="AfterBuild">

   67    

   68     <!-- Syncronize the database schema between the local machine and the staging server -->

   69     <RedGateSyncronizeSchema OriginDatabase="TestDatabase" OriginServer="MyMachine" OriginUsername="TestUser" OriginPassword="test" TargetDatabase="TestDatabase" TargetServer="StagingServer" TargetUsername="TestUser" TargetPassword="test" />

   70     <RedGateSyncronizeData OriginDatabase="TestDatabase" OriginServer="MyMachine" OriginUsername="TestUser" OriginPassword="test" TargetDatabase="TestDatabase" TargetServer="StagingServer" TargetUsername="TestUser" TargetPassword="test" />

   71 

   72   </Target>

I'll follow up shortly with a full article (probably two) documenting my adventure and the code I've put together.
Posted: Feb 04 2006, 11:42 PM by Plip | with 1 comment(s)
Filed under:
Dell 20" Widescreen

Dell 20" Widescreen
Originally uploaded by Plipster.
Just got a new Monitor for home, it's a Dell 20" Widescreen monster.

It's like having a whole new PC !
More Posts