Friday, November 30, 2007

KB936021 XML Core Services Update Breaks XSLT Transformation (which could be any BizTalk maps)

KB936021 - Microsoft Security Bulletin MS07-042 published on the 14th August 2007 which fixes the potential vulnerability of executing remote code via an XSLT file from within Microsoft Internet Explorer may break your BizTalk (all versions) implementation (or any XSLT transformation code) - Only applicable to BizTalk: but this is depending on how you have implemented your maps.

This update fixes, XML Core Services 3.0, 4.0 and version 6.0. Previously, the resolveExternals (part of the DOM interface) property was true by default allowing you to code something like the following in XSLT:-

<xsl:import href="addressbook_vv.xsl"/>

<xsl:call-template name="addressbookupdate_out_vv">
<xsl:with-param name="pdamgr" select="PDAMGR" />
This was possible before the fixpack because the DOM was true by default and BizTalk does not explicitly set it to true.

After installing this fixpack, the above code will not work because BizTalk uses the XML Core Services for XSLT transformation and doesn't explicitly set the resolveExternals property to true - which is what is required in order to call sub maps (sub XSLT templates within stylesheets).

But this depends on how you have written your maps in BizTalk. If you have used the BizTalk mapper or used .NET C#/VB.NET to create your maps then you will be OK. But the mapper tool is very inefficient so we have written our maps ourselfs by hand which use re-usable routines referenced as above. Now this is causing us an issue and will probebely have to be written in .NET.

UPDATE: In relation to BizTalk, Microsoft has told us there will probebly not be a hotfix in the future to allow you to set this property or force resolveExternals to true as they see this as a security risk.

If you are encountering an issue outside of BizTalk when trying to do a transformation with MS XML Core Services, then this is an easy fix. Simply set resolveExternals to true before you do the transformation.

Thursday, November 29, 2007

Anonymous Types: C# 3.0

Anonymous Types are a new feature available with C# 3.0 and VB 9. In fact one of many new features that is available with C# 3.0 or VB 9.0 (Visual Studio 2008, "Orcas"). This is a compiler feature not a framework feature. As with Implicitly Typed Local Variables, you only need the C# 3.0 or VB 9 compiler in order for your end users to use this functionality - not the .NET Framework 3.5. They go hand in hand with Implicitly Typed Local Variables. However, generally you will be using Visual Studio 2008 as who these days explicitly uses a command-line compiler to compile their code!!? Not many.

I have written an article on Implicitly Typed Local Variables, if you haven't read it yet, you can do so here.

Anonymous Types allow you to create an instance of a class without the need to write code for the class in the first place. Anonymous Types go hand in hand with LINQ and Implicitly Typed Local Variables. They must be coded in-line. Consider the following example:
new {Name="Simon Hart", Age=30, Married=True}
The above code needs to be assigned to a type. But what type? The type is anonymous! this where the other new feature of C# 3.0 known as Implicitly Typed Local Variables come into play by use of the new keyword - var.

So the above would look like the following when assigning to a Implicitly Typed Local Variable:
var person = new {Name="Simon Hart", Age=30, Married=True};
What happens when you run this code? Well the following image shows the types that have been inferred to their assumed types:
Clever stuff eh!? As you would expect the other properties; Married is of type boolean and Name is of type string.

I know what you're thinking, "why would I want to do this". Well the answer is for many reasons and in lots of places. Sometimes you create types that you are not too concerned about and the lifecyle is very short. Other times you have an designed an encapsulated type that will never be exposed to the outside world. In addition the power comes when using this with LINQ. You can use LINQ without Anonymous Types and in fact without Implicitly Typed Local Variables, but it makes your life a lot easier to use these new features. It allows you to craft you're own types at runtime, maybe based on what the user has requested. When you get to grips with LINQ, Anonymous Types are very powerful.

I will be publishing many articles on LINQ very soon..

Wednesday, November 28, 2007

Implicitly Typed Local Variables: C# 3.0

Remember var's - well if you are a native VB or a COM or even an OO COBOL developer you will have almost certainly used variants/objects. Var is a new keyword used in C# 3.0, but don't mistake it for a variant or a typeless object - it is far from it.

The var keyword allows you to define a variable whose type is implicitly inferred from the expression used to initialize the variable. The var keyword is basically a compiler trick, there is no difference in the generated IL when implicitly delcaring the var from explicitly declaring the integer. So you could code the following in C# 3.0 which is perfectly legal:
var i = 0;
After executing the above code the CLR sets the type to an integer. i is strongly typed, and treated the same as defining an integer variable. So the above is the same as the following:
int i = 0;
As you can see the var has been inferred to an integer value type:

One requirement is that the var is initialized on the same line as the var is declared and the intializer must be an expression. So you couldn't code:
var i;
Trying to compile the above code will give a compiler error: "Implicitly-typed local variables must be initialized":

You also couldn't set i to null attempting to do this will generate compiler error "Cannot assign to an implicitly-typed local variable".

So the following is invalid:
var i = null;
You also must define the var in-line. You cannot define the var outside of the member, event, property etc attempting to do this will generate compiler error "The contextual keyword 'var' may only appear within a local variable declaration":

So we have covered the basics of implicitly typed local variables and I bet you're probably thinking, what is the point of them, I mean doesn't this just make you're code more difficult to read?

Well the point of them is they go hand-in hand with LINQ and Anonymous Types. LINQ is a set of extensions to the .NET framework 3.5 that encompass Language Integrated Query set and transform operations. LINQ is available with C# 3.0 and Visual Basic 9. You will need the C# 3.0 or VB 9 compiler and .NET Framework 3.5 to use LINQ which come with Visual Studio 2008. In addition, var is generally used with Anonymous Types.

I have written an article on Anonymous Types, if you haven't read this yet, you can do so here.
I will be writing some articles on LINQ soon...As LINQ is very powerful and will make our jobs as developers easier. I can see LINQ simplifying the data layer completely. I've never liked the complexity of ADO.NET - it's too problematic which is why I have been using the enterprise library data application blocks from the pattern & practices group for ages now. LINQ is going to make data access even easier and more importantly, cleaner.

But .. I will talk more about LINQ to come. There is a lot of information on LINQ in the communities - which is great, the sooner everyone starts using it the better!

HTC Touch Cruise

A very cool device released recently by HTC named the HTC Touch Cruise:

It is a very high-end Windows Mobile Professional device with the following points of interest:

  • GPS chipset
  • 400 MHz Qualcomm processor
  • Windows Mobile 6 Professional
  • 3G (UMTS) support
  • 3 mega pixel class
  • 256MB ROM
  • 130g in weight
  • Built-in FM radio
  • HTC's TouchFLO interface - much like the iPhone technology
Very very high-spec.

Sunday, November 25, 2007

C# 3.0 Language Specification

Get the C# 3.0 language specification here. I was going to buy a book on the subject, but thought, what the heck I'll read the spec written straight from the engineers who designed C# as we know it.

Extension Methods: C# 3.0

A new feature in C# 3.0 is extension methods. I must say I like extension methods - very much. They allow you to extend any type transparently (without having to derive from it). The best thing is, this is not a .NET 3.5 feature, in other words it doesn't require .NET 3.5, but *does* require the C# 3.0 compiler. So if you want to implement this functionality today, your users do not require .NET 3.5.

How many times have you wanted to check a value type such as an integer for nulls or zeros with ease. Previously you would've had to write something like the following:

Note: the ? indicates a nullable generic.

int? i = 0;

if (i == null || i == 0)
//Do something

The above code is fine, but we can simplify it.

Here's a simple example of its use:

1. Define a static class, the name doesn't really matter but the class must be static.

public static class IntHelper

2. Now implement a new method as follows:

public static class IntHelper
public static bool IsNullOrZero(this int? i)
if (i == null || i == 0)
return true;
return false;

The method must also be static and contain the this keyword before the type.

3. Now in order to use this extension, we could code something like the following:

int? i = null;
if (i.IsNullOrZero())
Console.WriteLine("i is null");

The above code is alot cleaner than testing for zeros and nulls. Of course you could let your imagine run wild with extension methods. But I recommend only using them for simple operations as your code could soon become too complicated which would then become more difficult to maintain especially when new developers come on board.

Thursday, November 22, 2007

Where has Windows Mobile 6 SDK gone!!?

After installing Visual Studio 2008 I was unable to target Windows Mobile 6 devices from within the '08 IDE - even though I have Windows Mobile 6 SDK installed and can still compile against WM6 in Visual Studio 2005.

This is a known issue by Microsoft and is a result of installing Visual Studio 2008 and to fix, simply re-install the Windows Mobile 6 SDK.

Wednesday, November 21, 2007

Extracting Visual Studio 2008 UDF from an ISO image

So you've just downloaded Visual Studio 2008 in .iso format from MSDN subscriptions...what now? Well you can burn this image to DVD then install from there. But what if you want to just extract the .iso and install from HD?

To do this you need a UDF (Universal Disk Format) compatible extractor. You can use either ISO buster (not free) or WinRAR which supports UDF from version 3.7 and onwards.

Tuesday, November 20, 2007

Visual Studio 2008 & .NET Framework 3.5 RTM is here!

UPDATE: If you are an MSDN subscriber and have the monthly MSDN shipments, VS 2008 will only be included from Jan 2008 and onwards and not before.

Yesterday (Monday 19th November 2007) the RTM version of Microsoft Visual Studio 2008 was released. You can download this via MSDN subscriptions or a 90 day trial version if you do not have an MSDN subscription.

I am downloading VS 2008 Team Suite edition as I write this blog entry. See here for more information. It is a rather hefty download at just short of 4 GB!

I am in the process of writing a blog entry regarding what's new for device application developers with the advent of VS 2008, so watch this space...

Thursday, November 15, 2007

SQL Server CE Performance Tips

UPDATE: This is a very good article:

As there have been a few questions recently in the communities regarding Microsoft SQL Server CE performance, I'd thought I'd post the following link which contains some useful information regarding SQL Server CE performance tips:

Also see here for information of changing the default temp table directory that SQL Server CE uses when processing transactions or large queries from RAM to a storage card which will also improve performance and reduce those annoying OutOfMemoryException exception's.

Also try using the DataReader class over the DataSet and ResultSet wherever possible if you don't need the scrollability, updateable and a bindable cursor as the DataReader will always be more efficient. I myself always use DataReader which populates a strongly typed collection which I can then use to bind to my controls where required.

You might also find this link interesting, written by Chris Tacke of OpenNETCF. It talks about data caching in SQL Server CE to improve performance.

Tuesday, November 13, 2007

Consolas Font Pack for Visual Studio 2005

Although this little gem has been released for sometime, I'd thought I'd post a link to the new font named Consolas.

Consolas is a new font created by Microsoft designed for ClearType and is intended for use in programming environments.

It is supported on XP and later. Installing the pack will set VS 2005 to use Consolas by default. Not too sure about previous versions.

Here are a couple of screen shots I created to illistrate the differences - although I admit it is very difficult to see the difference as Blogger has resized the images! I will be hosting my blog on my own server very soon once I have finished building it:

Courier New

Here is the new Consolas font:

You can download the pack from here:

Wednesday, November 07, 2007

Microsoft Commits to Visual Studio 2008 RTM Release Date

Announced at the Barcelona TechEd a couple of days ago (Monday 5 Nov) by Somasegar - the vice president of the developer division at Microsoft, Microsoft has committed to releasing the RTM version of Visual Studio 2008 and the .NET Framework 3.5 by the end of November 2007.

I myself was going to re-download the VS.NET beta 2 VPC image as the old one expired prematurely on the 1st Nov but I think I'll wait until the end of the month and get the RTM version.

A CTP release of the new Microsoft Sync Framework SDK is available now from here:

This framework we are currently testing looks very interesting indead. In the past we've had to write a load of plumbing code for synchronizing offline data on the device with the back office. The Sync Framework contains a set of API's that do all this complex code behind the scenes. These API's work for any protocol, data type of data store. Download and try it today. I am not sure that the Sync Framework will replace our complex sync code but it is definately an interesting solution. I will blog regarding my Microsoft Sync Framework experiences here.

Friday, November 02, 2007

Service Management Europe - Oct 24th - 25th 2007

Well last week we were an exhibitor at the Service Management Europe SME show hosted at the Birmingham NEC. I went up on the 24th (Wednesday) just to see who was there and to ensure the system worked and I was there in case of any problems arose, none of which did, thankfully ;) We used a Wi-Fi ad-hoc peer-to-peer network for communications rather than GPRS/UMTS for reliability and it worked great.

It was interesting for me to talk to other companies regarding their mobile solutions and what they are doing with it and how they are saving companies money in operation costs using their solutions. The show also had Seminars every 45 Min's or so which hosted real-world experiences from various companies that found using mobility software reduced their operation costs.

I must add to the above. Most of the people, in fact all the people I spoke to never once gave me any figures from real world clients a break down in return on investment ROI. I found this rather strange and somewhat shortsighted. If I were a decision maker looking to save in operation costs, the first thing I want to see is the ROI.

Needless to say I saw some very sophisticated systems each of which had their strengths and had their weaknesses. Remember this show was about Service management, so it only covers mobility in the service management space. But boy, is this a up and coming area - for sure no doubt about that. It reminds me of when ERP - Enterprise Resource Planning systems first came about, now today, ERP is a very competitive business and only the large companies tend to win the business. Service management is still for the taking.

I also noted 90-95% of the solutions were written for Windows Mobile/Windows CE.

A lot of companies were using GPS in their solutions, some primarily GPS, others used it in their arsenal of tools, which in my experience is the best thing to do.

I saw some very impressive job scheduling solutions which used GPS.

Overall the show tended to be a lot busier in the morning then in the afternoon. In the afternoon it got a bit quieter.

To sum up, all the solutions had their strengths and weaknesses. Putting all these strengths together for the average service provider company, you would have a very, very functional system that would deliver ROI in no-time.