Vuzix Wrap 1200VR

Definately keen on seeing the reviews on this product once its out!

My main concern would be the readability of small text, seems the be the weak point of lower res VR solutions until now.


Session randomly expiring


I had just deployed a new website to my production server running IIS. The client was testing, but complained that the session was timing out too soon.

The website was using a check on session variables to see if the user was logged in and the session was still valid , something like this

 if (Session[“CustomerID”] == null)
                Response.Redirect (“~/SessionExpired.aspx”);

On testing myself it seemeed the session data was randomly expiring. In the development environment there was no problem. I checked the usual culprits: session timeouts in the web.config, IIS session settings, if the anti-virus was touching certain config files etc. No luck…

Then I noticed that the application pool under which the website was running was set to allow 2 worker processes! aha!


According to the MS documentation “The in-process session state mode stores session-state data for an ASP.NET application in the worker process where the application runs. This mode is the default for IIS 7.”

The user would login successfully, session data would be stored under that workerprocess. BUT because of the whole http is stateless thing, the user could be randomly swapped to the other workerprocess, which has no knowledge of their previous session data. As the session data was no longer present, my code would inform them their session had expired.

I’m not sure why the pool had 2 workerprocesses allowed, but after setting it to the default of 1, the problem was resolved.

If you’re working with a web-farm or some such dealing with multiple processes then their are alternatives to the InProc sessionstate mode, such as using a SQL server or the ASP.NET State Server service to store session data.

XML validation using XSD succeeds when the XML is invalid

Problem: I inherited a bit of code from previous developers. This loaded a XSD into the readersettings and attempted to validate a received XML document.

What I noticed however is that the XML document ALWAYS passed the XSD validation, even though it was correct. Eventually I found a post describing a possible cause of the problem. My XSD had a namespace explicitly defined. The XML I received had no namespace. For some reason because the XML is NOT in the namespace of the XSD it will always pass the validation…wierd.

Solution: Create a default namespace. The XML will automatically be defined as being part of the namespace and hence will be validated against the XSD correctly.

I copied this code from the interwebs, but can’t remember where, so sorry for the lack of credit to the original author.

Something like this

XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;

settings.Schemas.Add(null, HostingEnvironment.MapPath(schemaLocation));

settings.NameTable = new NameTable();
XmlNamespaceManager nameSpaceManager = new XmlNamespaceManager(settings.NameTable);
nameSpaceManager.AddNamespace(“”, “xxxNAMESPACExxx”);
XmlParserContext parserContext = new XmlParserContext(settings.NameTable, nameSpaceManager, “”, XmlSpace.Default);

XmlDocument xmlDoc = new XmlDocument();
XmlReader reader = XmlReader.Create(contentStream, settings, parserContext);

Root Element is Missing (reading XML)

Problem: While trying to read a stream containing XML twice, I kept getting the error ‘Root Element is Missing’, even though the XML was 100% correct.

After searching the net for a bit I came across an article about streams and the position in that stream (thanks Edward Weinert). After seeing this I realised that the 1st read was moving the position in the stream to the end. The 2nd read was starting from the end of the stream, and therefore finding NO root element in the XML.

Solution: The concept of the solution is simple, set the position to 0 after the stream has been read. The code was somewhat harder, but thanks to StackOverflow I found the solution. (

Stream responseStream = CopyStream(resp.GetResponseStream());
// Do something with the stream
responseStream.Seek(0, SeekOrigin.Begin);
// Do something with the stream again

private static Stream CopyStream(Stream inputStream)
const int readSize = 256;
byte[] buffer = new byte[readSize];
MemoryStream ms = new MemoryStream();

int count = inputStream.Read(buffer, 0, readSize);
while (count > 0)
ms.Write(buffer, 0, count);
count = inputStream.Read(buffer, 0, readSize);
ms.Seek(0, SeekOrigin.Begin);
return ms;

Windows FTP “User Home Directory Inaccessible” error

Problem: I was only trying to create a simple FTP test folder. So I created a local user, create a folder in the inetpub/ftproot/localuser folder and set up all the rights.

But everytime I tried to login I got the error “User home directory inaccessible”

Eventually I asked a collegue, who didnt really know either, but was willing to help. So she deleted the user and folder and tried again…no luck. So she created another user and folder and suddenly, it worked! Mysterious? What was wrong with the original user and folder names?

Solution: After a bit of searching I came across the following article

In the article it described something called ‘user isolation’ .

I won’t quote the article because you can read it yourself. However it states that when using user isolation there MUST exist a directory within the localuser folder (when using local users and not domain users) with the same name as the user. As far as I can tell it WONT work otherwise.

So if you create a FTP user ‘localmachine\BobsYourUncle’  there must exist a folder …’\localuser\BobsYourUncle\’ within your root FTP folder.

Very very interesting.

Debugging Stylesheets

This  is more a handy tip than anything else.

Problem: I had created a website using dynamic stylesheets. Running on my machine and all developers machines around me it looked fine. Then I deployed it for testing and the problem appeared. On the testers machine, also using IE8 the site looked different! I couldnt figure out why until a collegue suggested he check his compatability view.

As it turns out normal Pc’s here have compatability view mode enabled by default through the domain settings. So everyone is running in IE7 mode. At least I had found part of the problem, my website wasnt IE7 compatible. The next problem was WHY? What was I using in my CSS that was specific to IE8?

Solution: After scratching my head on how I would find the erroneous CSS element I hit on the idea to use something I hardly ever do, IE8’s built in ‘Developers Tools’ (F12)

Using this I opened up the page, and then one-by-one enabled and disabled CSS elements related to the page I was viewing and the part of it that wasn’t showing correctly. It didnt take long to find 2 elements I was using that were causing a problem in IE7.

Datagrid Visibility and DomainDataSource DataView Count


The problem was relatively simple. Hide or show a datagrid depending on whether the datasource had rows or not.

I created a converter that converted the datasource row count to a visibility property, and implemented it like so

 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            DomainDataSource lv_item = value as DomainDataSource;
            Boolean lv_rowsExist = (lv_item.DataView.Count > 0);

            if (lv_rowsExist)
                    return Visibility.Visible;

            return Visibility.Collapsed;

<sdk:DataGrid Visibility=”{Binding ElementName=domaindatasource1, Converter={StaticResource domainDataSourceRowsToVisibilityConverter} ….etc

And subsequently the converter was NEVER called after I called the datasource load event….I was baffled.


Once I found the solution it was pretty obvious, and perhaps those of you using the MVVM design pattern would have spotted it right away.

Anyone created a MVVM viewmodel knows to implement a PropertyEvent changed handler. Its called a PROPERTY event changed handler for a reason. I knew the DomainDataSource would implement something like this, but why wasnt it firing when I loaded data? Well…it was. I had just bound my the visibility of my datagrid to the DomainDataSource object itself..not a property. When loading data the DDS itself wasnt changing…so there was no reason to call the converter.

The solution of course was to bind the Visibility to the DDS Data Count PROPERTY! Like so

Visibility=”{Binding ElementName=domaindatasource1, Path=Data.Count, Converter={StaticResource domainDataSourceRowsToVisibilityConverter}….etc

This property DID change everytime I loaded data, and ergo the converter was properly called.

I won’t forget this one to soon!

Global BusyIndicator for DomainDataContext


With Asynchronous calls in Silverlight its important to let the user know something is happening when they request data. At first I put a BusyIndictor in the Navigation content, which was ugly because it left a large border showing around the BusyIndicator for those elements that are not part of the Navigation content.


What I was looking for was some way, on an application level, to show a BusyIndicator. I came across this post by Bryan Sampica which was very useful.

This worked perfectly on a DomainContext level, BUT, I was using a bunch of DomainDataSources, which would always be busy for longer than the DomainContext itself. Which meant the BusyIndicator dissapeared before the actual data was available…what a pity.

So I kept the concept of using a BusyIndicator as the rootvisual, but ditched the domaincontext class extension. And then just manipulated the Global BusyIndicator depending on whether the DomainDataSource is loading or not.

Something like this.

BusyIndicator busy = (BusyIndicator)App.Current.RootVisual;
busy.IsBusy = true;

private void DomainDataSource1_LoadedData(object sender, LoadedDataEventArgs e)

BusyIndicator busy = (BusyIndicator)App.Current.RootVisual;
                busy.IsBusy = false;

The DomainDataSource1’s LoadedData event is handled by DomainDataSource1_LoadedData

Images not showing at runtime


Just came across this frustrating little quirk. I’ve defined all my logos and background images etc. in the Silverlight stylesheet Styles.xaml. Both the images and stylesheet are in the /Assets/ folder. The images all showed fine at design time, but at runtime none showed.

No combination of back/forward-slashes, absolute paths, using PNG’s vs GIFS, changing the build action of the images etc made a difference.


So I went back to the basics. I dragged and dropped an image control onto the master page, and set the resource to point to one of my images. And this is what the codebehind ended up looking like:

<Image Source=”/TrackAndTrace;component/Assets/Logo.png” />

Applying this logic to my Stylesheet solved the problems!

Strangely enought microsofts documentation didn’t provide my with any insight to this method of specifying an image source. So I’m not sure WHAT it is I’m actually specifying and WHY…which is always frustrating.

Is ‘TrackAndTrace’ a reference to a path, the application name, the namespace???

MVVM or domaindatasource

I spent a day delving into the basics of the MVVM model and implementing it in my current project. It took me several hours to implment a simple example using strict MVVM practises. Using DomainDataSource takes me minutes to do the same thing.
The only info I find on the interwebs regarding DDS vs MVVM boils down to “Don’t use DDS, its bad practise”….I’m not convinced. But they days are young. I expect that somewhere down the road I’ll realise I’ve made a huge design flaw and end up refactoring/redesigning everything…hehe