Using XSD/XML With LINQ; Serializing and Deserializing – Visual Studio .Net 4.0

In this example i am using VS2010 with .Net 4.0 as the framework.

The XML i am using is:

<!--?xml version="1.0" encoding="utf-8"?-->





Located in VS2010, and most likely VS2008 is the CreateSchema option in the XML menu, this becomes available when editing XML documents.

Using create schema on the above XML sheet would create a XSD document as below:

Using the XSD tool (Found in C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\xsd.exe with VS2010) it is possible to create a LINQ query-able Dataset/Class from XML.

Running the following from a CMD prompt will generate a class file that you can use in your application:

“C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\xsd.exe” C:\_DEVELOPMENT\Your.xsd /c /eld /edb /o:C:\_DEVELOPMENT\

What the command line parameters mean:

  • The Location of the xsd.exe
  • The Location of your xsd file
  • The Arguments:
  • /c indicates we are creating a class.
  • /eld indicates we are creating a dataset that can be queryable by LINQ
  • /edb indicates we are to allow data binding
  • The destination of the class file, in this instance it will be called Your.cs and placed in the C:\_DEVELOPMENT\ dicrectory.

Import the Your.cs class into the project you are working on.

I Have used all the following namespaces, plus the standard ones for a application/webapp:

using System.Diagnostics;
using System.IO;
using System.Security.Permissions;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

//The following function can de-serialze the ‘Convert Object’ from an XML document
public Convert GetConvert(string FilePath)
Convert res = null;
if (System.IO.File.Exists(FilePath)) //Check to see if the file is there
using (FileStream fs = new FileStream(FilePath, FileMode.Open)) // Load the file into a file stream
using (XmlReader reader = XmlReader.Create(fs)) // Create an XMLReader from the 
XmlSerializer serializer = new XmlSerializer(typeof(Convert)); //Prepare a serializer, with the Convert Object type
Convert deserializedconverts = serializer.Deserialize(reader) as Convert; // Deserialize an object
res = deserializedconverts; // * return the deserialized object.
return res; // * return the deserialized object.
//The following function can serialize a ‘Convert Object’ to an XML Document
public bool WriteConvert(string FilePath, Convert input)
using (FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate)) // Open or create a file named by the filepath param.
XmlWriterSettings writerSettings = new XmlWriterSettings() { Encoding = new UTF8Encoding(false) }; // set the encoding to UTF8
using (XmlWriter writer = XmlWriter.Create(fs, writerSettings)) // Create a new xml writer
XmlSerializerNamespaces names1 = new XmlSerializerNamespaces(); names1.Add(“”, “”); // Remove any silly microsoft namespaces
XmlSerializer serializer = new XmlSerializer(typeof(Convert)); // create us a serializer
serializer.Serialize(fs, input, names1); // serialize the object.
return true; // if it worked return true
catch (Exception ex)
return false; // if it didnt work return false


That’s essentially it, You may have to add references to both the System.Xml.Linq and the System.Data.DataSetExtensions if you get build Errors.

Copying Data Between/Within Tables in Sql

Simple method of copying data between tables or within the same table in SQL.

The following can be used to copy data within its own table, altering fields as required:





954 as Some_Id,
FROM Table1 where Some_Id = 52

The following can be used to copy data from a different table:





43 as Some_Id,
,[Name_First] + ‘ ‘ + [Name_Last]
FROM tblStaff where Job_Title  like ‘%developer%’

Download and Use the old Windows Live Messenger 2009

Well Forgive me, I’m not normally one to rant(Ed. okay that may be a lie).But this time it’s almost serious!

Since the dawn of the blue screen, Microsoft have been royally screwing things up for the likes of you, me and everybody else.

Now they have unleashed their greatest stagnation upon the masses; Windows Live Messenger 2011 (Wave 4) . Not only has it got all the gloss of a polished turd, its got more bugs than a fisherman’s hut.  its also got a brand new terrible interface combined with the removal of some very useful features that the previous versions had.

Apart from giving me a case of the grumps..lets see what they’ve given us…

  • Tabbed conversations… We already had this with msn plus
  • A redesign of how the emoticons look how useful.
  • The ability to ignore Bing search not only from your browser, but now from within msn as well!
  • Connections to various social networks.. Okay that could be useful, but its handled in a most cumbersome way.
  • Integration with Facebook chat…Really ? why ?
  • OOOOH BADGES …erm no

Though on the flip side of the coin, here are some of the more useful things they have removed:

  • One way web cam support, you can no longer Send my web cam or View this contacts web cam instead you are forced to do some kind of Skype-esq video call which resembles half the quality of Skype but double the annoyance.
  • The abolition of contact Import/Exports.. This one really is beyond me, Why do this? okay sure i never used it.. but i could have?
  • Display names are now royally screwed up.
  • Oh yes, sorry folks, if your using anything other than Vista/Windows 7 your no longer supported.

Now you all may think I’m just a mad man ranting about a situation with no solution, a wolf crying in the wilderness? Well not exactly; There are alternatives.

For years aMSN has been developing, it is an open source alternative to the run of the mill, its free, very easy to use and works on most major platforms(Windows,MacOs,Linux etc..).

I’ve used that for awhile, but when I’m on a windows machine I still prefer the style n feel of the older msn clients…that’s why i have provided this Earlier version of Windows Live 2009.

Just un-install the latest one, via the program / features part of your control panel.

Another useful tool I use to wallow away the days is MSN plus, with polygamy( in the non marital sense) and various other tools it makes the MSN experience a bit more bearable.

A Small Update 24th Feburary 2011

Some of you may now be getting:

A newer version is available. You must install the newer version in order to continue. Would you like to do this now ?

Microsoft now deem it a requirement for you to update again to a later version, once again removing features. I am including a small replacement for the msnmsg.exe file, simply copy it into your windows live messenger directory (most likely: C:\Program Files\Windows Live\Messenger)

You will still need to install the version of Windows live messenger 2009 above.

The msnmsgr patch can be found here. Just simply replace that msnmsg.exe with the one in your Windows Live Messenger directory and all should work fine!

Happy hunting.

Beeker MSN

Dungeon Master Javascript

Could this be the height of my retro 80’s/90’s gaming obsession I hear you ask?

Well quite possibly..probably not though.

Dungeon Master Javascript is my version of the 80’s classic Dungeon Master By FTL Games.

The entire ‘game’ is written in javascript and CSS, it should be CSS2 compliant but I have used a few CSS3 methods..

You can control where you are in the maze by using the Arrow keys on your keyboard, or by clicking on the arrow icons in the interface.

The logistics of the game are quite complicated. The main premise of its functionality revolves around a 2-dimensional array of javascript objects, which divide the ‘squares’ into 5(North, East, South, West and Center) and these have a various properties too..

The visualization takes place by scanning upon movement the present location of the player/view-port in relation to the map, creating walls where it sees fit. The same goes for the doors.

This game will not work in obsolete browsers, and if it does it may be buggy..

There is no pre-loading of data at present. This means it may appear to be malfunctioning when its just loading data/graphics.

In time I hope to develop it further, however with the advent of HTML5 the methods I’m using may seem rather redundant to the modern gamer. Especially with 3d/GL developments.

I cannot take credit for the Dungeon Graphics.. they were taken from the example module of Return to Chaos…and other various old pseudo 3d games.

The source code is freely available, if you do use it though please credit/comment me 🙂