Run as domain user

As mentioned in a previous post, when Visual Studio connects to external resources like Team Foundation Server, it uses your Windows credentials by default. I already explained how to use the Run as different user hidden option of the context menu. However this option doesn’t allow you to use domain accounts (at least that was the case when I wrote this post with Windows 7 and Visual Studio 2012). As a consultant, I sometimes need to use my own computer when visiting customers, which is of course not attached to their domain. There is definitely a solution to fix this issue. The following command indeed allows you to run Visual Studio as any user, even a domain user:

runas /netonly /user:MyDomain\MyUser “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe”

The command prompt will then ask you to enter the password for the account you specified. That’s it! You are now running Visual Studio as a domain user.


Run as different user

By default, Visual Studio uses your Windows credentials to connect to external resources like Team Foundation Server. But sometimes you would like to connect with another account. If I stick to my TFS example, if my account doesn’t have the rights, a dialog box will appear so that I can enter the credentials I want. But otherwise, it will automatically connect and there is no integrated feature to switch to another account. You could of course go to the credentials manager and delete them but this is quite tedious. There is however a small Windows tip many people don’t know. You probably already know the Run as administrator option which is available in the context menu of most applications since Windows Vista. Well you know what, Visual Studio provides an additional option to use any account to run the application. For this purpose, you just have to hold the Shift key before right clicking the Visual Studio icon. You’ll then see the Run as different user option
(Figure 1).


Figure 1

No more PDB files at build

When you build a Visual Studio project, a file in generated in addition to the assembly. It has the same name but has a different extension: PDB for “Program Database”. This file contains all the debugging and state information of the project. It allows you, amongst others, to be able to break the execution at a breakpoint when you are debugging. Although those files are extremely important in development phases, they may be useless in release, depending on your deployment strategy. So it is interesting to now how to get rid of them at build. For this purpose, open your project’s properties page and go to the Build tab. At the bottom, the Output section owns an Advanced button (Figure 1).


Figure 1

Click this button to open another window. The parameter  is Debug Info. It has three options: none, pdb-only and full (Figure 2).


Select none and save your changes. Congratulations, you got rid of PDB files!