Using KnockoutJS with SignalR in ASP.NET MVC

KnockoutJS is a MVVM implementation for JavaScript written by Steve Sanderson, in my opinion the author of the best ASP.NET MVC textbooks available. Simply put it lets you bind a JavaScript object model to your HTML UI using a Read more

A MongoDB Tutorial using C# and ASP.NET MVC

In this post I'm going to create a simple ASP.NET MVC website for a simple blog that uses MongoDB and the offical 10gen C# driver. MongoDB is no NOSQL database that stores information as Binary JSON (BSON) in documents. I Read more

Linq To SQL Tutorial

Check out some of my other Linq to SQL posts: EntityBase Inheritance Modifiers with SQLMetal Linq to SQL with WCF Services Linq to SQL Framework (Repository/Business wrapper) ObjectDataSource binding with server side paging and sorting Load Options Generic Framework using reflection This is a basic tutorial for Read more

Remove nuget packages from a project in Visual Studio and restore from packages.config

Posted on by Joe in ASP.NET, C#, Visual Studio 2008 | Leave a comment

I was recently in a situation where I multiple projects in solution that needed the same nuget packages, but a lot of unnecessary packages had also been added.

Firstly I wanted to quickly remove all of the nuget packages in a single project which can be done by entering the following into the Package Manager Console.

Get-Package -ProjectName "My.Project.Name" | Uninstall-Package -ProjectName "My.Project.Name" -RemoveDependencies -Force

Next I added just the packages I needed to that one project. The next step was to quickly update all of the other projects to have the same packages.

For each project I ran the same command as above to remove all the packages, then copied the packages.config containing the correct package information into each project. It’s then possible to restore all of the packages from the packages.config using the following command.

Update-Package –reinstall -ProjectName "My.Project.Name"

Running MSTest on your build server without Visual Studio

Posted on by Joe in Visual Studio 2008 | Leave a comment

Recently I had a problem where I added a Visual Studio Test Project to a solution.

As part of our CI, the build server failed to build as it didn’t contain the necessary files for the test framework. One option would have been to install Visual Studio Team System on the build server, but it seems a bit crazy to do that just to get the tests to build.

I found a post here by Mark Kharitonov that explains a method to get tests building without having to install Visual Studio which worked perfectly for me.

Creating and using snippets in Visual Studio 2008

Posted on by Joe in Visual Studio 2008 | Leave a comment

Visual Studio contains a number of predefined snippets. Snippets are usually available for common code that is used frequently allowing the developer to insert this code quickly without having to retype it every time. I often use the try and if snippets, but you can also create your own custom snippets. Recently I found myself to be endlessly creating a try/catch block where in the catch I was logging an exception using a custom logger class, so I decided to create a custom snippet to do this for me. In this post I’ll explain how to create a basic snippet, how to configure Visual Studio to use the snippet, and how to use it in code.

Read more

Visual Studio closing when trying to choose items for the toolbox

Posted on by Joe in Visual Studio 2008 | Leave a comment

The other day I was trying to add new items to my toolbox in Visual Studio 2008 and each time Visual Studio would close itself without reason. I tried the Reset Toolbox option which didn’t solve the problem.

I then tried running Visual Studio in safe mode by choosing run from the start menu and typing ‘devenv /safemode’. In safe mode I was able to get the Choose Items dialog so I just flicked through all the tabs to make sure it was working. I then closed Visual Studio and loaded it normally and everything worked as expected.

Not sure why it happened but this seemed to fix it :)