Word 2007 Test Post
IT Chapters No Comments »Since we’re implementing the Metaweblog API in our company’s blogging software today, I thought I would test Word 2007’s blogging features on my blog. Holding thumbs!
The Wikipedia Explorer
IT Chapters, Link of the Day No Comments »I love graphical representation of data. Back in the day, I did my thesis on the graphical representation of intrusion detection systems’ output to manage threats effectively. I was even published in a book. But enough of that self back scratching, lets talk WPF.
Yes, WPF. Windows Presentation Foundation. A wonderful new technology from Microsoft that really pushes the envelope of desktop GUIs. I think WPF needs a blog post on its own, so I’ll do that this week and give some cool demos that are out there on the interwebs. I’ve been playing around with it last week and built a very basic RSS reader with some cool visual effects quickly and surprisingly easy. There is a great article here on how to get your machine kitted out for developing a WPF app. Give it a shot.
But the main focus today is an application built by the friendly people at Dot Net Solutions. Disclaimer: I am an employee.
Using WPF as the backbone, we’ve come up with a great way of experiencing the Wikipedia world without leaving your desktop. Dubbed Wikipedia Explorer, this application allows you to navigate around Wikipedia in ways that really show the inner links of Wikipedia.
Using the different views available, such as the Network view, a graph is built up on how articles are linked together. Its awesome! The 3DExplorer view allows you to see in a 3 dimensional view the articles linked in a page but the Network view blows you away. Give it a try, its been stitched together using ClickOnce so you’re always up to date.
Links:
A blog post on the Dot Net Solutions Blog.
The case study page I wrote.
Download!
.NET 3.0 is also required.
The Power of Community
IT Chapters, Photography, Zooomr No Comments »Since I’ve joined Zooomr and taken photography a little more seriously (but still enjoying it a massive amount), its amazing the power of community. The days that I’ve taken photos and come back and deleted most if not all of them, the comments from the Zooomr community has really made the difference. The positivity from the people have really allowed me to get through the dark times where no shot seems to work well and it all seems worthless. After a quick look through what Zooomr have done, really does lift the spirits.
Thomas and Kristopher, keep up the great work and well done on helping this community foster. ![]()
ASP.NET Caching Gotcha
IT Chapters No Comments »In an application I’ve been developing, we store the menu structure in an XML file. This was a .NET 1.1 application so it was before we had the chance of using the wonderful new controls in ASP.NET 2.0. I was developing today with my laptop was under some high load when the application stopped running and threw exceptions whenever the menu was being rendered. Can anyone spot the mistake in the code below?
if (Cache[”MenuDocumentXML”] == null)
{
//Create the dependency
System.Web.Caching.CacheDependency _MenufileDepend = new CacheDependency(Server.MapPath(”~” + “\\Menu.xml”));
//Get the file from the webroot and load it
System.Xml.XmlDocument MenuDocument = new XmlDocument();
MenuDocument.Load(Server.MapPath(”~” + “\\Menu.xml”));
//Insert the item into the cache
Context.Cache.Insert(”MenuDocumentXML”, MenuDocument, _MenufileDepend, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
}
return (XmlDocument) Cache[”MenuDocumentXML”];
The code here checks the cache for an item with the key MenuDocumentXML. No prizes for guessing what that contains. If it doesn’t exists, we create a filedependency on the actual xml file, load the xml file into an XMLDocument and then put this into the cache. The cache item expires after 30 minutes and will expire immediately if the file on disk changes.
The problem actually occurs in the last line. I’ve taken for granted that right after I added the item to cache it will be available. When the item doesn’t appear in the cache, we load it in, and outside the IF, we just pull the Menu directly from the cache.
However, my system was under load, and immediately after adding the item to cache, it was falling out, so the cache didn’t hold it anymore and therefore I was returning null every time.
The correct code should look like this:
System.Xml.XmlDocument MenuDocument;
if (Cache[”MenuDocumentXML”] == null)
{
//Create the dependencies
System.Web.Caching.CacheDependency _MenufileDepend = new CacheDependency(Server.MapPath(”~” + “\\Menu.xml”));
//Get the file from the webroot and load it
MenuDocument = new XmlDocument();
MenuDocument.Load(Server.MapPath(”~” + “\\Menu.xml”));
//Insert the item into the cache
Context.Cache.Insert(”MenuDocumentXML”, MenuDocument, _MenufileDepend, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
}
else
{
MenuDocument =(XmlDocument) Cache[”MenuDocumentXML”];
}
return MenuDocument;
In this example, when nothing is in the cache, we store the loaded XMLDocument into a variable immediately and then return that. In the case that the XMLDocument is in cache, we load it from the cache and then return it to the calling method.
Something small, but this is a gotcha that could potentially trip up your system.
