Visual Studio

Shortcut: Including a Namespace

**UPDATE**: I’ve been fat-fingering everything lately. I messed up and typed the comma, when I meant a period. I have updated the post to reflect the proper fix. 

Right now I have ReSharper turned off on my client’s machine because it bogs down the machine. There’s a lot of encryption going on to the hard drive so my guess is that this is the culprit. Reason being: I can run VS2010 with ReSharper installed on my laptop and its smoking fast, and it has 1/2 the power of the desktop. Odd.

Since I’m not using ReSharper I need a way to quickly include namespaces of a type that I’m using. Up until now, that shortcut has been SHIFT + ALT + F10.

This is not the case with VS2010.

The shortcut is now CTRL + .

That will give you a little popup menu asking if you’d like to include the namespace in the current file. You can do all of this from the keyboard, therefore saving yourself some time.

Updated Visual Studio Settings

Previously I had uploaded my dark themed visual studio settings. These settings were created prior to using the Spark View Engine for my web development. I have updated the settings to include support for the Spark View Engine views. Here’s a screenshot of what the HTML view looks like. Download the settings file at the bottom of the post.

image

 

Download

DonnFelker-20090526.vssettings (~341 KB)

Presentation Settings for Visual Studio

Unfortunately most presenters do not think about font size until about 10 _after_ they show code to an audience. Its usually followed by the confirmation question from the presenter that goes something like this: “Hey, can you guys see the code?”

Most of the time the answer is… “No, bigger font please … ”. 2 minutes later the font is larger, but usually its only the code editor window. What about the solution explorer, output window, menu’s, etc? Nope, it is still an 8pt font that strains your audiences eyes.

Big Font to the Rescue

I have a Visual Studio Settings file that I call “WowThatsABigFont.vssettings” that I use when I’m presenting. I’m going to attach to this post so you can use it in the future.

Here is what it looks like (click to see full res picture):

image

These settings are at 16 pt Lucinda Console (for most everything) and 14pt Consolas for the environment.

 

You have no idea how much this improves your presentation. People can read the screen! This coupled with ZoomIt makes it super easy on your audiences eyes.

Enjoy.

 

Download

WowThatsABigFont.vssettings (~375kb)

Debugging Silverlight Tip

If you’re doing any kind of Silverlight work you’re bound to get “Error on page” in Internet Explorer. Here’s what I’m talking about.

You fire up your app in the browser window and BLAM. Screen is empty and you get the “Error in page” error. Double click the error and you get an Internet Explorer JS Error Window. Here it is in all its glory:

 image

 

How Do I Catch The Exception in Code?

The exception IS happening in code you’re just not catching un-handled exceptions.

To turn them on, go to Debug –> Exceptions:

image

You’ll get the window below. Check the “Common Language Runtime Exceptions” checkbox and click OK.

image

 

You will not get exceptions bubbled up to the Dev Environment. Here’s what it looks like in action  (with the same error as the “blank screen” above).

image

 

Click “Break” and break into the area where the code barfed on you, and then clean up the mess you’ve created (on accident of course – who creates un-handled exceptions for fun anyway). :)

 

Enjoy.

Visual Studio Project MSBuild Import Error Fix

If you get this error:

Unable to read the project File <path.to.project>.csproj.

C:\<path>\<to>\<projecct>\Project.csproj 77, 11): The imported project “C:\Microsoft.CSharp.targets’ was not Found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

As shown in this screen shot …

image

 

Take a look at your project file. Open it in a text editor (such as NotePad++) and look for the import statement.

Mine looked like this:

clip_image001

 

How to fix

Change the MSBuild Property $(MSBuildToolsPath) to $(MSBuildBinPath) and the project should load.

Like so:

clip_image001[7]