Optimizing Code Snippets

Code Snippets are a great productivity boost that was introduced in Visual Studio 2005, if I remember right. Code Snippets lets you type a shortcut for a piece of code. I use snippets for properties a lot. I hate writing properties “by hand” – it is much faster with Code Snippets. But since Visual Studio 2008, the default prop shortcut now uses Dynamic Properties – but I still work on some projects that does not support Dynamic Properties. So I changed my default Code Snippets, and added a few other. First I changed the default prop snippet back to the old property with a backing field. Then I added snippets for a Dynamic Property, Business Object Property (to use with Rockford Lhotka’s CSLA architecture) and a ViewState Property. See the code they all produce here: This boosts productivity even more, … Continued

How to handle IIS Event id 1009 (Event id 5011 on IIS 7)

Recently at work we had some serious production environment issues. Our web application basically made the IIS application pool terminate unexpectedly. And we didn’t get a single stack trace or a line of code. The only thing that was logged inside of the Windows Event Viewer, was event id 1009, which basically told that the application pool serving our app terminated unexpectedly. And that was it. All active user sessions were wiped, and the users had to login again. The error started after we did a major upgrade. A lot of our code had changed since the previous version, so we set up an new website and application pool inside IIS 6.0 for the new version, so we could upload the new application, and then turn off the old one, to get as seamless an upgrade as possible. It worked … Continued

Recommended listening: .NET Rocks with Brad Abrams

If you haven't heard .NET Rocks before, now is a good time to do it. In their last show, they interviewed Brad Abrams during Remix Boston where he did a keynote. So who is Brad Abrams. Quote from his own blog: Brad Abrams was a founding member of both the Common Language Runtime, and .NET Framework teams at Microsoft Corporation where he is currently the Group Program Manager for the UI Framework and Services team which is responsible for delivering the developer platform that spans both clients and web based applications as well as the common services that are available to all applications. Specific technologies owned by this team include ASP.NET and ASP.NET AJAX, parts of Silverlight, and Windows Forms. In the interview, they talk a lot about Silverlight, what they are trying to do and how open the technology … Continued

Silverlight 1.0 officially released

This morning, I just read over at Scott Hanselmans blog, that Silverlight 1.0 was released and it support Linux. So that means Silverlight support all major platforms now, and it is out in the open so your apps can get going. To get some inspiration, you can have a look at these Silverlight apps that Scott posted on his blog: (posted from ScottGu’s blog) Quote Scott Hanselman Recreating ITunes in Silverlight: Jose Fajardo has an absolutely fantastic blog with a ton of Silverlight content on it.  One of the projects he has been working on has been recreating Apple’s ITunes Media Player using Silverlight.  Check out his multi-part blog series that discusses step-by-step how he built it.  Absolutely brilliant. Sudoku for Silverlight: David Anson has built a cool online sample using Silverlight that helps you play the popular Sudoku game.  Useful … Continued

Web services and Silverlight 1.1 C# gotchas

As anyone must know by now, Silverlight is Microsoft's cross-browser, cross-platform RIA (Rich Internet Application) technology – like Adobe's Flash. With Silverlight, they say the sky is the limit, and it's only up to yourself what to invent. Silverlight offers you a big chunck of the .NET CLR in the browser, when using Silverlight 1.1 Alpha (Refresh). As always, there are do's and don'ts when you work with new technology and in this not-known-yet-part series, I'm going to recap my experience using Silverlight 1.1 Alpha and later Silverlight 1.1 Alpha Refresh to develop some sophisticated charting components. Before you begin – general info For the current release of Silverlight (Silverlight 1.1 Alpha Refresh) you don't have the System.Data namespace (that means no DataSets nor DataTables). Also the System.Xml namespace is very small, you don't get the XmlDocument which would have been … Continued

Fiddler2 and the ASP.NET Development server (Cassini)

If you’re debugging ASP.NET apps, it can sometimes be an advantage to be able to see the actual requests, and analyze file sizes, run-time rendered code and being able to ‘fiddle’ with the code on run-time. Well. Fiddler2 provides extremely useful features for doing so, but for people using the ASP.NET development server (Cassini) you have to do a few workarounds… I’m running IE7 on Windows Vista (a great OS). IE7 automatically bypasses proxies for localhost, which is our main problem. When using the ASP.NET development server (Cassini), the URL looks like this one: http://localhost:49950/app/Default.aspx. When you open Fiddler2, you see that it hasn’t monitored the traffic to the localhost address. This can be fixed by applying a period (.) after localhost. So change the URL to this:  http://localhost.:49950/app/Default.aspx In my case, that wasn’t enough. I got an error from Fiddler2 … Continued

Set the DataTable.Locale property – or get weird sorting

If you have a monster of an ASP.NET app, and your user come from different places in the world, they are most likely to have different locales as well. I’m danish, and we have three special characters in our alphabet – æ, ø, å. If I have a DataTable with – let’s say firstname and lastname columns. I create my DataTable like this: DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn(“Firstname”, typeof(string))); dt.Columns.Add(new DataColumn(“Lastname”, typeof(string))); dt.Rows.Add(new object[] { “Øjvind”, “Jensen” }); dt.Rows.Add(new object[] { “John”, “Nielsen” }); dt.Rows.Add(new object[] { “Åse”, “Østergaard” }); This is how I DataBind my GridView: if (!Page.IsPostBack) { GridView1.DataSource = dt.DefaultView; GridView1.DataBind(); } With my regional settings on my machine (which in this case is also the webserver) we get the correct sorting: The GridView sorted by Firstname ascending. But if I go ahead and change … Continued