Rants Tagged with “Visual Studio”

1  2  3  4  5  >  >>  (Total Pages: 5/Total Results: 49)

My Favorite Visual Studio Shortcuts and Snippets

Keyboard Shortcuts

I've been speaking at user groups and conferences for a long time now. Usually at these short talks I don't get asked much about how I use Visual Studio.  But now that I am teaching Silverlight, my students are never shy about asking what I am doing while in Visual Studio.  I am often amazed by how people use Visual Studio without learning some of my favorite hotkeys/snippets.  Here are some of mine:

Keyboard ShortCuts

  • Ctrl-Shift-B: Build Solution
  • Ctrl-. (period): Show "Add Using/Imports" dropdown for unknown types.
  • Ctrl-K, C: Comment Selection
  • Ctrl-K, U: Uncomment Selection
  • Ctrl-K, F: Format Section
  • Ctrl-K, D: Format Document
  • Ctrl-Space: Show Intellisense List
  • Ctrl-Shift-V: Paste Loop - Hit Multiple Times to paste through the list of recent 'copies'
  • Ctrl-F: Simple Find
  • Ctrl-Shift-F: Find in Files
  • Ctrl-H: Simple Replace
  • Ctrl-Shift-H: Replace in Files
  • Ctrl-N: New->Project Item
  • Ctrl-Shift-N; New Project
  • F9: Set Breakpoint
  • Ctrl-Shift-R: Start/End Temporary Macro Recording
  • Ctrl-Shift-P: Play Temporary Macro Recording
  • F12; Navigate to Type (or metadata for Type) under the cursor

Snippets

(To use these snippets, type the phrase and hit Tab twice)

  • prop: Create a simple property in a class
  • propg: Create a simple property with a public get and a private set
  • foreach: Create a foreach block
  • sldpc: Create a Silverlight Dependency Property*

* This snippet is from the Silverlight Contrib snippet collection.

What are yours?

Blend and Visual Studio - Why Two Tools?

Silverlight Logo

I am here at DevTeach and having a great time. I got in a discussion with several of the speakers about the common complaint of some Silverlight/WPF folks that they want Blend to be in Visual Studio; or why Cider has always been disabled by most dev's.

I hear the complaint a lot that developers want the functionality of Blend hosted in Visual Studio.  While I understand the desire, I've never been bothered by the dual programs. In fact, I think its better. Blend needs to be separate because its primarily for a Designer/UX role that isn't comfortable with the breadth of Visual Studio.

We have plenty of other solutions that have two overlapping tools: I can insert an Excel spreadsheet in Word but when I need to do an if/then analysis I use excel.  A single Office App would be silly. Finally (I think the most compelling example) is SQL Server.  When I am in Visual Studio, I can open a database connection and run queries, create stored proces and more.  But if I want to manage users, create backup plans or other DBA-like tasks, I go to SQL Server Management Studio. I can do many of the same tasks in both, but developers never ask for Microsoft to remove SQL Server Management Studio and fold it all into Visual Studio.  Different roles mean different tools (roles != people btw). 

What do you think?

Running Silverlight 2 and 3 On Same Machine - Redux!

Silverlight Logo

I've been using Amy Dullard's great batch file for switching the tools back and forth between Silverlight 2 and Silverlight 3. It works great except that it doesn't change the runtime. And while the Silverlight 3 runtime *should* run any Silverlight 2 code fine, I just don't trust it. So I had to make it better.

I've made a small change in Amy's batch file to uninstall and install the right runtime, but there is a hitch. You need to download the runtimes yourself (as they are downloaded during installation and since Amy's batch is opening up the Setup package, they aren't there).

To use the batch file you'll need to download the file (here) and unzip it into an empty directory.  Into that directory copy the following files:

You can download them by clicking on the links.

If you haven't done so already, run the Silverlight 2 Tools Package and the Silverlight 3 Tools Package.  Finally you can run the Setup_SLTools_Util.bat file that is in the zip file.  This will create new batch files for moving two and from SL2/SL3 for Visual Studio and Visual Web Developer Express.  Please see Amy Dullard's post about it for more information about how the batch files are used:

http://blogs.msdn.com/amyd/...silverlight-3-tools-to-silverlight-2-tools.aspx

 

When is a ASP.NET Project Not an MVC Project?

Silverlight Logo

I am working on a hybrid ASP.NET MVC and MVC Dynamic Data project. To work on it I started with the MVC Dynamic Data project assuming this would be a Dynamic Data Project and an MVC project. As Scott Hanselman recently posted, you can mix and match pretty easily so the code was working but I was missing an important piece of functionality in Visual Studio:

My project wasn't being showing these items (or other menu options specific to MVC apps). I suspected it was some magic in the project file so I opened it up in my favorite editor:

<Project ToolsVersion="3.5" 
         DefaultTargets="Build" 
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">
      Debug
    </Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{F7526D86-12B4-434F-8355-20592CFC4937}</ProjectGuid>
    <ProjectTypeGuids>
      {603c0e0b-db56-11dc-be95-000d561079b0};...
    </ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Foo.Web</RootNamespace>
    <AssemblyName>Foo.Web</AssemblyName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
  </PropertyGroup>

The missing bit was a special ProjectTypeGuid: {603c0e0b-db56-11dc-be95-000d561079b0}. You need to add this to the existing ASP.NET project's ProjectTypeGuid list in the project file and magically the project item types appear.

HTH

Congratulations Sara Ford!

Silverlight Logo

After 382 Visual Studio Tips and a book, Sara is retiring the series.  Those tips have been hitting my RSS Feed for a long time now. They've been helpful to me and my students. I really appreciate all her hard work helping us in the community.

Sara Ford's Blog

Silverlight Logo

I am surprised when I talk to developers these days and they don't know who Sara Ford is.  She's responsible for CodePlex and many open source initiatives at Microsoft. In addition, her blog is an excellent source of information on Visual Studio tricks and features that most of us have never noticed.  It is well worth a read. Just announced today, her blog is now available in Russian and Spanish so if English isn't your native tongue, you're in luck there too.

Wonder how I get someone to translate my blog into other languages ;)

The Document Outline in Visual Studio 2008

Silverlight Logo

Something I never noticed before is the Document Outline window in Visual Studio (2008?).  When editing large XAML files this is particularly useful to help navigate the tree of elements.

If you've never noticed it like me, you can make it show up by using the menu's when a XAML file is open:  View->Other Windows->Document Outline. Alternatively, the default key command is Ctrl-Alt-T.

This is *not* a Silverlight specific feature.  It works with WPF as well (but not ASP.NET pages). Nice....

 

 

 

 

Regionate Can Cause LINQ to SQL to Fail

I've been using a LINQ for SQL model for a project for a few months now.  The project has been compiling fine forever now.  Suddenly it was failing to build the .dbml file for no apparent reason.  A quick search for the problem turned up an issue with Regionate and LINQ for SQL.  Uninstalled Regionate and its back to compiling. 

I like the tool but until they fix the issue, i'll have to live without it for a while.

Visual Studio 2008 PowerCommands

Not sure when these were released but someone on Witty mentioned this release. Its a cool number of little features for Visual Studio:

  • Collapse Projects
  • Copy Class
  • Paste Class
  • Copy References
  • Paste References
  • Copy As Project Reference
  • Edit Project File
  • Open Containing Folder
  • Open Command Prompt
  • Unload Projects
  • Reload Projects
  • Remove and Sort Usings
  • Extract Constant
  • Clear Recent File List
  • Clear Recent Project List
  • Transform Templates
  • Close All

Go grab them now.  You know you want them...

Getting Silverlight XAML Intellisense in VS2008

bad intellisense

I've gotten the question a number of times about problems getting intellisense with Visual Studio 2008. If your XAML looks like this in Visual Studio 2008 then I can help you:

 

 

 

 

right click menu

The problem stems from the fact that VS2008 wants to open .xaml files in the WPF Designer. Instead you can get intellisense and a better-faster experience if you open your Silverlight XAML files in the XML Editor.  Most people assume that the intellisense is the lack of the Silverlight XSD file in the installation, but in fact VS2008 includes the Silverlight XSD document (but is unaptly named WPFE.XSD). To solve the problem of opening the file in th wrong editor, right click your XAML file in the solution explorer and pick "Open With..." (see right).

 

 

 

Open With... Dialog

Once that dialog is open, you can pick the "XML Editor" and it will open the file with full intellisense.  I usually click the "Set Default" button as well to always open XAML files (for both WPF and Silverlight) in the XML editor.  I use Blend to edit these files and I am not a big fan of the built-in editor (as it seems to be designed mostly for Windows Forms developers to create simple experiences.  You can see the "Open With..." dialog below:

Let me know if you have any questions!