Blog Archive
Windows Vista, Visual Studio 2008 and IIS7
After upgrading to Windows Vista, I’ve had many problems with Visual Studio 2008 and IIS 7 on it. This blog post discusses some problems and how to solve them.
IIS 7 does not allow ports on Windows Vista
After reinstalling Windows Vista, Visual Studio 2005 & Visual Studio 2008 on my computer, I started having problems with using dynamic ports with ASP.NET.
DataGridView SelectionChanged event behaves strange
In this post, let’s look at how to fix the DataGridView
SelectionChanged
event if it starts to behave strange.
json_encode works bad with UTF8
I have had some serious problems with UTF8 and PHP’s built-in JSON functionality. After solving it, I realized that it was not even an UTF-8 issue, but a JSON one.
My first thoughts on TDD
After an interesting conference talk on Test and Behavior Driven Development (TDD & BDD), I have now started using NUnit to write unit tests in C#. Here are some initial thoughts from a TDD n00b.
Identifying the project root in PHP
I currently have problems with identifying the project root in a PHP project. The problem applies to PHP, but is general and applies to other languages and environments as well.
jQuery Flash MP3 player download error
I am currently having problems with the Single MP3 Player with the jQuery Flash plugin, which fails to download files in other folders.
Make URL rewriting in IIS 7 work like in IIS 6
I’ve had a lot of problems with getting URL rewriting to work with Windows Vista and IIS 7. Compared to IIS 6, virtual paths in IIS 7 don’t allow extensions like .js, .css, by default.
Generate HTML documentation from C# comments
In .NET and C#, XML comments is a good way of documenting the code. These comments can then be used to generate HTML documentation. Let’s have a look at how.
Get the week number of a date in C#
This post was written in 2009. Although the logic hasn’t changed since, the implementation has. For the lastest implementation, check out NExtra on GitHub.
Find all classes that inherit a certain class
In a typed language, it can be handy to retrieve all types that inherit a certain base class. Let’s have a look at how to do this.
Using themes in ASP.NET MVC
I’m building a web site with ASP.NET MVC. After looking at the nice examples, I noticed that CSS files were manually included in the master page. Let’s use themes instead.
JSON serialization in C#
From time to time, I forget where various classes in the .NET framework are defined. For my future self and those of you who also struggle, here’s a short tutorial on how to get JSON working in C#.
Use special characters in ModelState error message
In this post, let’s take a look at how to use special characters (like « and ») to model errors that we can use with ModelState
.
Easily paginate collections in C#
In this post, we’ll create two extensions that lets us easily paginate any collection in C#.
Show all files in Finder
This post will show you how to easily show all hidden files in Finder, both with a Terminal script and a keyboard shortcut.
Doxygen - A brief tutorial
I’m using Doxygen to generate a web-based documentation for various .NET projects. This post shows how to configure Doxygen to achieve this.
MacBook swollen battery
I have previously written about my numerous problems with my new, white MacBook, which I purchased in August 2007. As icing on the case the battery has now swollen.
XOT-Uzg TV Streaming on your Xbox
I recently picked up my old, black Xbox from the basement, where it has lived in solitude since I bought my Nintendo Wii. Since it is old and much has happened with the video game indistry since it came out, I don’t game on my XBOX anymore. Let’s look at some media server fun you can have with it instead.
NSUserDefaults
As I’ve started to look into iOS development, I have created a test app with a tab view and four views (the $$$s are not far away). I now want to store data without a database. Can this be done?
Using shared libraries in iOS
After a couple of evenings, my first (really simple) iPhone app is taking shape. However, I’m currently struggling with reusing functionality across apps.
A* implementation for XNA
I have recently been playing around with the XNA game framework that can be used to develop games for the Xbox 360. It’s fun, but different from the code I usually write. For instance, I’m currently trying to implement the A* pathfinding algorithm in C# for a board game that I’m working on.
Visual NUnit 2010
I have a license for R# at work. It’s a really nice utility that saves me a lot of time. Besides providing a lot of shortcuts and extensions to Visual Studio, it also integrates NUnit in a convenient way.
Bundle CSS files with relative file paths
I’m currently working on a css bundler, where aim to bundle files from different folders into a single file. This post describes how I had to replace content bundling with import bundling.
/ in URL query makes CSS @import and file paths fail
I am currently implementing css file bundling with virtual paths in php and am facing a problem, where slashes in the url query make file imports fail.
ConstraintException is thrown when posting empty data for non-nullable properties
I am working with model validation in .NET, Entity Framework 4, DataAnnotations
and
partial classes with MetadataType
connections and now have a problem where exceptions
are thrown when posting empty data for non-nullable properties.
DataAnnotations and MetadataType fails in unit tests
This post describes how to fix model validation for ASP.NET MVC 2, when testing a model that uses DataAnnotations and MetadataType to describe for its validation.
Getting familiar with PHP 5.3.2
Since I’m just pretending to be a PHP developer, I only just now started to use PHP 5.3.2. The reason for this is that I just installed Aptana Studio 2, which comes with PHP 5.3.2 installed.
Getting the name of the current controller and action in ASP.NET MVC
I have been trying get the name of the current controller and action in ASP.NET MVC, and have found a nice way to do so. Let’s see how to do this.
Bundle JavaScript and CSS files with full file paths
I have looked at the great php-based css and JavaScript bundling approach that is presented at rakaz.nl. The approach in that post works great, but has a small drawback.
NuPack - a quick walkthrough
NuPack is a free, open source, developer-focused package manager for .NET. It looks great, so I downloaded it and gave it a try. Let’s have a look at how to use it.
PHP magic quotes
I’ve had problems when sending data to a PHP page, using AJAX. To unpack the data, I had to use stripslashes
. It seemed to work, and I was happy, until the world exploded.
Moving ViewState to the bottom of the page
ASP.NET’s ViewState
is a way to simulate state in a stateless web environment. It’s a cool technology, but is unfortunately easy for developers to misuse.
Make Combres work with ASP.NET
After having problems with SquishIt when bundling JavaScript, I decided to give Combres a try. However, while SquishIt works right away, Combres must be configured quite a bit.
ImageGen Cache Problem
I am looking to use Umbraco ImageGen in a project that I’m currently working on. People who have used it really seem to like it, so I look forward to try it out. However, I did run into a cache problem.
Adding Spark to ASP.NET MVC 2
I finally got some time to look at the Spark View Engine. Since the Razor View Engine will be shipped with ASP.NET MVC 3, I decided to give it a try.
Flush the Visual Studio Template Cache
I recently created a project template that uses the Spark view engine instead of the default Web Forms view engine. However, it didn’t show up in the project template list. Time for a template cache flush.
Spotify background playback problem on iOS
Sometimes, Spotify stops being able to play music on iOS when it’s sent to the background. Whenever this happens, you may have to free up memory by removing some background apps.
Automatically convert HTML5 to HTML4
I love HTML5, although it will take time for many browsers to support HTML5. Until they do, our code must be supported by older browsers as well. What if I told you that there’s a way to write HTML5 today, and automatically have it convert to HTML4 whenever needed?
Calculate geo distance and bearing in C#
I’m building a GPS-based web application that lets mobile devices post their position, then replies with nearby points of interest (POIs) like restaurants, bars, etc.
WampServer URL rewriting problem
I have a hobby project that works great on MAMP, but that doesn’t run so good on WampServer, which seems to handle url rewriting differently. The fix turned out to be easier than expected.
Hide the close button of a WPF window
I want to hide the close button of a WPF progress window, to prevent users from closing it manually. It was complicated to achieve, but perfectly doable.
Custom ASP.NET validation attributes
ASP.NET validation attributes is a great way to validate C# properties in different ways, both client & server side. Let’s look at how we can create our own validation attributes.
WPF WTF
My personal WPF WTF list has grown steadily since I started to work with WPF. In my opinion, WPF is filled with bad naming conventions and inconsistencies. Here are some examples.
Embed Git Bash into Visual Studio
I have started to use git in my .NET projects. It works really well, but I’m having problems with integrating it in Visual Studio. Turns out there’s a way to add a Git Bash window to Visual Studio.
Running Facebook authentication on localhost
I have started building an ASP.NET MVC3 site that uses the Facebook API to create and authorize users. It’s easy to setup, but running it on localhost requires some configuration.
Localizing a WPF application with resource files
This post shows how to localize a WPF application that consists of a main app and several DLL projects that provides the app with general user controls, model classes etc.
NUnit BadImageFormatException
In a project of mine, NUnit suddenly started to warn that something’s wrong with the assembly. Turns out that accidentally disabling architectures is a bad thing.
Open file with the keyboard in OS X
Although I love OS X, I am still new to it and a Windows user by habit. As such, the unintuitive and secret clubesque keyboard shortcuts are not one of my most favorite parts with using OS X.
Visual Studio and WPF applies basic Windows 7 theme
Each time I open a WPF project in Visual Studio (2010) and open a XAML file, my computer switches from the semi-transparent theme to Windows 7 Basic.
EditorBlockFor HTML helper
In ASP.NET MVC, Microsoft has created various HTML helpers that can be used in a form, e.g. LabelFor
, EditorFor
, ValidationMessageFor
. Let’s see how to create a custom one.
TeamCity 6.5.1 does not play well with NServiceBus
I am currently moving some projects from an old TeamCity 5.1.2 server to a brand new 6.5.1 server. Everything has been going great, until I tried moving a project that uses NServiceBus.
Am I writing bad tests?
To grow as a developer, there’s nothing better than to invite others to criticize your potential flaws. This post will expose my shortcomings as a unit test loving developer. Enjoy!
Where do I put the logic?
I could use some advice regarding a project that I’m currently working on, where people can sign up and join various groups (did I hear “Facebook is already doing that”?). I’m now torn on some implementation details and would love some discussions regarding where to put certain pieces of logic.
Various NDepend learnings
I’ve been using NDepend to analyze the latest version of my NExtra library. The code is overall good, but the code analysis highlights some interesting design flaws that I should fix in the next version.
Use Phantom/Boo to build, test and publish to NuGet and GitHub
When building open-source, each release involves unit tests, bundling, zipping & uploading to GitHub & NuGet, creating new git tags, etc. Automated build scrips to the rescue!
Dependency Injection gone too far?
I am currently working with a new version of a hobby console application project of mine. The app will execute certain actions depending on the input arguments.
Posting source code on a WordPress hosted blog
At the time of writing, this code-oriented blog was hosted on Wordpress. Since I post a lot of code, I wanted the blog to have nice syntax highlighting. This is how you do it on Wordpress.
CLGeocoder fails silently
I’m currently developing a location-based app for iPad and iPhone, that will allow users to store locations and use custom icons and colors for the pins.
Activating Windows 8
Inspired by Øredev and all the great sessions, I finally installed Windows 8. I decided to upgrade my Windows 7 installation, and found the installation quick and painless….and the activation a nightmare.
Git not found in Mountain Lion
I recently updated OS X Lion to OS X Mountain Lion on all my personal computers. The installation was smooth, but afterwards some things did not work as expected. For instance, git was no longer found.
Natural Scrolling in Windows 8
Apple introduced natural scrolling
in OS X Lion, which makes the scroll content move as if it was a sheet of paper that you press and dragged around with your finger.
Entity Framework Code First with auto migrations on AppHarbor...and more
I’m building an iOS app that has an ASP.NET MVC 4 backend that uses Entity Framework Code First with auto migrations and runs on App Harbor. We also have a site that is used to present more information. This is how we put it all together.
Windows 8 Activation Fail
Unlike Apple’s great OS X onboarding experience, The Windows onboarding is horrible. If you charge money to use your OS, activation must work. Too bad, it doesn’t.
Mouse scroll sensitivity in Parallels Desktop
I use Parallels Desktop to run Windows from a dedicated OS X partition. It works great, but I have had problems with the mouse scroll being too sensitive. Let’s see how to fix it.
sudo is required for all Ionic and Cordova commands
I’m currently building my first Ionic Framework app. It’s fast to setup and performs well, but I ran into a problem that forces me to use sudo
for all Ionic & Cordova commands.
ASP.NET and WebApi attributes with StructureMap
After some time away from .NET, ASP.NET and WebApi, I have a great time setting up a new WebApi solution for a project at work.