Could not load file or assembly ...

If you ever caught the infamous error:

Server Error in '/ws' Application.

Could not load file or assembly 'App_Web_6sedkqth, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

And application pool recycling, site restart or even the good old iisreset won't fix it, then it might be a problem with ASP.NET temporary files.

The solution is stopping IIS (alternatively, you can just stop a specific application pool):

iisreset /stop

Deleting all the files (or part of them, if just stopped a specific application pool) from the following directory:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

And restart IIS:

iisreset /start

Note: this is basically a repost from my previous blog.

TFS: what to do when someone in company leaves or their PC dies?

The title is self-explaning :)

cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
tf workspace /delete workspace;mydomain\myuser /s:http://server:port/tfs_instance_name

A deleted workspace cannot be recovered.
Workspace 'workspace;mydomain\myuser' on server 'http://server:port/tfs_instance_name' has 32 pending change(s).
Are you sure you want to delete the workspace? (Yes/No) y

Typically the workspace has the same name as your machine.

Note: this is basically a repost from my previous blog.

Windows Azure Emulator with Microsoft Source Control

It appears that the Windows Azure emulator that comes with Windows Azure SDK doesn't like services with the Web.config file with the read-only attribute. It happens that that's exactly what SourceSafe and TFS do when a file is not checked-out. Do these guys work in the same company? Or does the Azure team use Subversion and git? ;)

Note: this is basically a repost from my previous blog.

Death to the .user!

A couple months ago, one of my VS solutions would just crash with a specific project. After a couple of hours, I've found the solution: close Visual Studio, delete all the "*.csproj.user" files, and reload the solution. My theory is that this was caused by TFS merges, since this solution had a few dozen projects and was frequently updated by various users, which in turn caused frequent conflicts. It's no wonder that these files are listed in .gitignore.

Note: this is basically a repost from my previous blog.

Country/language codes for CultureInfo

If you work frequently with internationalization/globalization you've probably questioned which cultures are supported in the CultureInfo class. As far as I know, there is no such page in MSDN. However, for the record, the code is composed by a two letter lower case ISO code for language (e.g. "pt", "en") and two letter upper case ISO code for country (e.g. "PT", "US"), separated by the hyphen character ("-"). Both of these codes are documented in Wikipedia as ISO 3166-1 alpha 2 and ISO 639-1, respectively.

Note: this is basically a repost from my previous blog.

Update (2013-03-12)

If you need to match cultures with countries (via the ISO 3 letter code), the following MSDN page might be useful: National Language Support (NLS) API Reference.

SessionState and ViewState in ASP.NET

Fine tuning ASP.NET applications is a very extensive topic. However, some features are enabled and may not be needed. For example, Session and ViewState are not really needed for simple pages (i.e. if your ASP.NET page is basically hosting a single page application in Silverlight). To do this, just open the .aspx (markup) file and add the last two attributes:

<%@ Page Language="c#" AutoEventWireup="true" CodeBehind="Foo.aspx.cs" Inherits="Acme.Foobar" EnableSessionState="false" EnableViewState="false" %>

Note: this is basically a repost from my previous blog.

.gitignore for Visual Studio 2010

If you are using an IDE to develop your applications (who doesn't these days?), you have probably stumbled on a lot of files that are automatically generated which you don't really need to add to source control. If you are using Visual Studio and plugins/extensions (such as ReSharper and NuGet) these are quite some files.  The ".gitignore" file was designed to solve just that: putting it in the root of your source control directory will prevent "git add ." commands from adding those files/directories. My current file is based on this one from github, with extensions from this one from stackoverflow, and finally a line that I added for ReSharper user files.

You can download the file here (be sure to remove the ".txt" extension).

Note: this is basically a repost from my previous blog.


Creating a GIT repository in Windows for cloud storage

One of the cool uses for cloud storage (such as Dropbox, SkyDrive or Google Drive) is as a git source code repository for your pet projects. Here's how to get started it in Windows.
But first, a couple of assumptions:

  • You have in your first machine a "Projects/Sandbox" folder with an existing project (e.g. a Visual Studio solution) and a "Dropbox" folder synched with the cloud; on the second machine a "Projects2" without any code and " Dropbox2" folder synched with the cloud. "dropbox" is the name of the remote repository.
  • You've previously added you git "bin" directory to your PATH environment variable.
  • You have Powershell installed (it's available for Windows XP or later). And yes, you could use the "classic" command prompt, but it's not as cool :) Really, if you're not familiar it's a good time to start using it.
So, launch Powershell and do the following:

# creating the remote repository
cd "C:\Dropbox\repositories"
git init --bare sandbox.git

# creating the local repository and first commit
cd "C:\Projects\Sandbox"
git init .
git remote add gdrive "C:\Dropbox\repositories\sandbox.git"
git add .
git commit -m "Initial commit"
git push dropbox master

# on a second machine, getting the repository
cd "C:\Projects2"
git clone -o gdrive "C:\Dropbox\repositories\sandbox.git"

Since I'm no expert on git, feel free to drop any comment about it Also, these instructions are adapted from this post, and mostly unchanged, as Powershell uses a UNIX-like syntax (actually, it uses aliases to do this, but you get the same result).

Edit (2012-09-05):
It seems that Google Drive has some issues syncing some files (e.g. HEAD and config) on Windows 7. The problem has been reported by other users. A workaround I found is to restart Google Drive when that happens, but that's not really interesting. I don't have these problems with Dropbox, though, so I recommend it instead. Haven't tested with SkyDrive yet.