Welcome to MSDN Blogs Sign in | Join | Help

The Visual Studio Blog

The official source of IDE, MSBuild and Extensibility information from the Visual Studio Platform Team
What's new for editor extenders in Beta 2?

Noah Richards Noah Richards – Developer, Visual Studio Editor Team
Short Bio:  Noah has been working on the Visual Studio Editor team since he graduated college two and a half years ago.  He maintains a blog, posts sample code for editor extensions, and frequently answers editor-related questions on Twitter.

Editor’s Note:  This post was originally published on Noah’s personal blog, which we’d encourage you to follow for additional content about the new VS 2010 editor and its extensibility.

Now that Visual Studio 2010 Beta 2 has been out for about a month, most of you have probably seen it and tried many of its new features.  For those interested in writing extensions for VS, we wanted to share a couple of updates around editor extensibility, particularly for people who wrote extensions in Beta 1 and want to upgrade to Beta 2.

1 – No More IEnvironment

If you wrote any code that had classifiers or taggers or various other extensions that take an IEnvironment parameter, you'll be deleting those parameters in Beta 2. IEnvironment had a few historical reasons for being there (back when the editor was a part of a different project and not in Visual Studio yet), but it wasn't really serving a purpose anymore. In Beta 1, all it really did was confuse people and make you type an extra few characters and/or add an FxCop suppression since you weren't using it. This is a small change but a simplifying one. (If you are curious about the one place that did use it for taggers, see #5 below).

2 – Mouse and key processors get more metadata

In Beta 2, mouse and key processor providers take the following metadata; note that some of these were required for mouse or key processors, but now the list applies to both:

  1. Export, like all components
  2. ContentType
  3. Name and Order, so that you can position yourself before or after other known handlers. This is important in cases where you want to preempt whatever normally happens in a certain event.
  4. TextViewRole

Also, somewhat tangentially, the ContentType attribute now applies to any buffer in a view's graph - that's just a fancy way of saying that if you have something like an ASP.NET page that has embedded C#, your key or mouse processors will get loaded if they have [ContentType("CSharp")].

These fixes were necessary to write the triple click extension, which selects a line on triple click (you can find its code on github and its binaries on the VS Gallery). Without the ordering, I couldn't put the mouse handler early enough to work correctly. Also, there were a few bugs in some of the default mouse handlers that have since been fixed.

Note that, unfortunately, the general guidance is to not use keyboard providers. The VS command system and the way components like the editor plug in don't play very well with normal WPF keyboard input, so the short story is that you'll only get keyboard events for key combinations that aren't already bound to a command. Which leads me to the next new thing...

3 – Listening for the creation of IVsTextView adapters (IVsTextViewCreationListener)

We added this as an extension to the VS integration piece of the editor to allow people to listen for the creation of IVsTextView (which is what the underlying IWpfTextView /ITextView are wrapped in for the sake of people who still use the existing VS API). It's effectively identical to IWpfTextViewCreationListener, except that you get an IVsTextView instead of an IWpfTextView when called.

A quick note – if you want to use this extension, you'll need to add a reference to Microsoft.VisualStudio.Editor.dll. It's in the SDK, so that's not a problem, but it isn't a part of any of the standard editor project templates.

The biggest reason we introduced this was for extensions that want to add command handlers to the editor. You could do this in the past, somewhat painfully, by doing the following:

  1. Write an IWpfTextViewCreationListener
  2. The ugly step - listen for the GotAggregateFocus event on the text view and do the remaining steps in that handler. If you skipped this step, the eventually attempt at getting the IVsTextView would fail, since the two objects weren't fully hooked up yet.
  3. With an [Import]ed IVsEditorAdaptersFactoryService, call GetViewAdapter to get the IVsTextView.
  4. Call IVsTextView.AddCommandFilter
  5. ...and don't forget to unsubscribe from GotAggregateFocus or use a flag so that you only listen to the first time the event is raised.

With the new event, you just need to:

  1. Write an IVsTextViewCreationListener
  2. Call IVsTextView.AddCommandFilter

If you do want to get the associated IWpfTextView for the IVsTextView adapter, you can do the opposite of #3 above (using GetWpfTextView); the upside, relative to the above list, is that you don't need to worry about initialization being finished. When you get the call in your creation listener, initialization has completed to the point that GetWpfTextView will always succeed.

Because command filters are still not entirely obvious to get correct, I'm working on a template to do this for you. More in general, I'm working on a set of "New Item" templates for the editor, so that you can add new components (or at least a skeleton of a new component) with a couple clicks in an existing project. I haven’t finished these yet, but you can see the work in progress on CommandFilter.cs.

4 – Custom text marker visual definitions

One of the other things missing in Beta 1 was the ability to set the visualizations for text markers (the markers you can create with an ITagger<TextMarkerTag>). There were some built-in marker types, but they were somewhat limited.

In Beta 2, that's now changed, and you can export a MarkerFormatDefinition that looks something like this:

Export(typeof(EditorFormatDefinition))]
[Name("mymarker")]

internal sealed class MyMarkerDefinition : MarkerFormatDefinition
{
    public MyMarkerDefinition()
    {
        this.ZOrder = 1;
        this.Fill = Brushes.Blue;
        this.Border = new Pen(Brushes.DarkGray, 0.5);
        this.Fill.Freeze();
        this.Border.Freeze();
    }
}

And then create a TextMarkerTag with the name "mymarker", and you are all set. Note that you'll probably want some transparency on your fill brush, since the selection is drawn underneath markers.

5 – View tagger provider (IViewTaggerProvider)

In Beta 1, you exported your taggers with an ITaggerProvider. In Beta 2, there is an additional interface you can use called IViewTaggerProvider, which is passed both a buffer and a view in its CreateTagger method. There are a few cases where you may want to use this:

  1. Your tagger needs information specific to a certain view – this may be the case if you are writing an extension that wants to, say, highlight all references in a view that match the reference under the caret. In this case, you need to know the caret position in the view to produce your results.
  2. Your tagger wants to produce different results depending on the view – this is basically the same as #1, but it may help to also think of it in this way. With the highlight references example again, it's possible to have two different views over the same buffer (split window, for example, or the code definition window), where you want each view to show different results for the highlighted references, even though they are displaying the content of the same text buffer.
  3. Your tagger wants to consume other tag information – this is a more complex case that probably deserves its own blog article. Basically, if you have a tagger for type T that consumes, say, classification tags, you want to avoid accidentally including a classifier that is trying to consume tags of type T, or else you'll end up with an ugly recursive loop when trying to get tags. You can sidestep this by providing your tagger with an IViewTaggerProvider and consuming taggers (or classifiers) you get from an IBufferTagAggregatorFactoryService (or IClassifierAggregatorService.GetClassifier that takes a buffer). That way, you are guaranteed that any taggers/classifiers you may consume can't accidentally consume your extension as well.

The downside to #3 is that it is still hairy for other components to safely consume your tagger (that they are using via IViewTagAggregatorFactoryService) to produce tags; if two view-level taggers are each consuming other view-level taggers, you get the same problem as before. As such, any component you make that does this should be created with the understanding that it can't be safely consumed. For any extensions you write, you should probably steer clear of creating view-level taggers that consume a view-level ITagAggregator<ClassificationTag>, for example. In general, it's probably safest to follow this rule:

Never create a tag aggregator using an IViewTagAggregatorFactoryService inside a tagger provided with an IViewTaggerProvider.

...and more

This is not an exhaustive list; these are just the biggest ones I can think of off the top of my head. We’ll continue to post more editor and extensibility content on the Visual Studio Blog and my blog, so stay tuned.  And as always, comments are welcome.

- Noah

Framework Multi-Targeting for VC++ Projects

Pavan (2)Short Bio: Pavan Adharapurapu is a developer on the Visual Studio Project and Build team. As part of VS 2010, he has worked on numerous features of the VC++ project system such as property sheets, filters, property pages, platform and tool extensibility, etc. His long term focus is on developing a "common project system" infrastructure which could be used to quickly build richly featured project systems. Prior to joining the Visual Studio team in 2008, he was working on Workflow technologies in Microsoft Dynamics Axapta. Pavan holds a Masters degree in Computer Science (CS) from the University of California, Los Angeles (UCLA) and a Bachelors degree in CS from the Indian Institute of Technology (IIT), Madras. He lives in Redmond, WA with his wife and loves to play soccer and watch movies in his spare time.

Have you ever wanted to target .NET Framework 3.5 with your C++ application in Visual Studio 2010? If you’ve upgrade your C++ CLR application or created a new one, you will notice that it automatically will target .NET Framework 4.0. However, with a little bit of work it is possible to have your C++ CLR application developed in VS 2010 and targeting 3.5. This blog post will explain just that. Please note that this post is about managed re-targeting for VC++ projects as opposed to

· Managed re-targeting for C#/VB projects (see ScottGu's blog post for this), or

· Native re-targeting for VC++ projects (Soma's blog post describes this).

I assume that you have a VS 2010 VC++ CLR project (.vcxproj) generated, perhaps, by the Visual Studio Conversion Wizard that you want to re-target to v3.5 framework version. Note that you can see the current framework version targeted by this project by going to the project properties UI and looking under Common Properties > Framework and References for the Targeted framework property (see snapshot below).

clip_image002

This field was a drop-down in VS 2008 and was the primary way one could re-target to a different framework version. In VS 2010, it is a read-only field. To re-target in VS 2010, we need to do some work.

First of all VS 2008 SP1 must be installed on your system (you cannot do without SP1). This is a mandatory requirement for targeting framework version 3.5. Installing only the .NET Framework 3.5 redist won't do. C++ tools like cl.exe in VS 2010 are only capable of targeting v4.0. So to target an earlier framework version, we need the tools from that earlier version. And these tools are shipped with VS and not with .NET Framework.

Next, you need to manually edit the project file (.vcxproj) with a text editor (like notepad) and add the TargetFrameworkVersion property (if it is not already there) as shown below. It is recommended that this property be added to the property group labeled "Globals".

image

If you use VS IDE itself to edit the project file (you have to first Unload Project and then choose Edit MyProject.vcxproj from the context menu of the project in the solution explorer), you will get the very helpful intellisense (see picture below) that will aid you in the definition of this property.

clip_image005

Once this property is defined with the right value, reload the project and verify that the Targeted framework property mentioned at the beginning of this post shows v3.5.

Diagnosing Toolbox Filtering Errors

me_small Hi again – Josh here, Toolbox developer.

If you've created or installed a toolbox item, but it doesn't appear in the toolbox when the appropriate designer is active, the first thing to do is select "Show All" from the toolbox and check to see if the item is there at all.  (The new search feature might help.)  If the item is missing altogether, that's a topic for another blog post, but I'll briefly suggest you start by looking in the activity log (run "devenv /log" to generate it).  If the item is present but disabled, there are a few reasons why this may happen:

1. There is no designer active, or the toolbox wasn't notified of designer activation for some reason.  (This notification should happen automatically without any explicit action from the designer itself.)

2. The designer doesn't implement IVsToolboxUser.  (This interface is needed in order for the toolbox to determine which items should be enabled for this designer.)

3. The item is tagged with a "mimimum required framework version" value that is greater than the project's framework version.  For example, the item might require version 4.0 of the .NET Framework, but the project is targeting version 3.5.  (This value is deprecated in VS 2010 in favor of more descriptive metadata (see the following three bullet points), but is still supported for compatibility.)

4. The item's list of supported target frameworks does not include the project's target framework or any lower-version framework of the same ID.

5. The item's assembly and/or type cannot be found in the profile targeted by the project (if the project's target framework does include a profile).

6. The item is hidden because there is another item representing the same type from a higher-version assembly which is also compatible with the current designer and project.

7. The designer's IVsToolboxUser::IsSupported method indicated that the control is not supported.

To help determine which of these is the case, create a DWORD registry value called "ShowDiagnosticToolboxTooltips", set to 1, under HKCU\SOFTWARE\Microsoft\VisualStudio\10.0.  Restart VS, open the project and designer, turn on "Show All" if it isn't already on, and hover the mouse over the unexpectedly disabled item.  The tooltip should include some text explaining why the item is disabled:

toolbox_tip

In this example, the creator of the item only indicated it was compatible with .NETFramework v4.0, but the active designer’s project is targeting v3.5, so the item is disabled.  A similar message could be displayed if the item was compatible with the project, but there was a higher-assembly-version item with the same type name; that’s what the portion about “best fit (among all items with the same typename)” means.

This requires VS 2010 Beta2.

Can I host a VSIX on my own server?

Several of our VSIP partners have asked me if they can host their VSIX file on their own server and what would the user experience be?

To answer the first question, yes, you can host your VSIX file on your owner server.  It doesn’t have to live on the Visual Studio Gallery.  Customers who visit your website can download the VSIX file directly.  When prompted to Run or Save, they can run the VSIX or save it to disk and double click on it to start the install.  Both installation methods will use our out of process installer.  During the install of Visual Studio, we register the .VSIX file extension.  Anytime the .VSIX file extension launches, our out of process installer will take over and install the extension for you.  The look and feel will be a bit different from the main Visual Studio Extension Manager installation experience but it works just as well :)

If you’re an extender that can’t host your VSIX file on the Visual Studio Gallery, here are two suggestions to make sure your customers have a good experience with your product.

  1. Create an entry on the Visual Studio Gallery.  You can do this by:
    1. Click on the Upload button
    2. Select Tool and click Next
    3. Select “I would like to share a link to my tool”
    4. Enter the URL to your website (this can be a direct link to the VSIX or to a landing page for more information)
    5. Click Test Link to try it out
    6. Click Next
    7. Add meta data to your extension
    8. Click “Create Contribution”
    9. Click Publish

Once you’ve added the entry, your extension can now also be seen in the Extension Manager UI.  When someone tries to download the extension from the Extension Manager or the Visual Studio Gallery, they will be taken to the URL you directed them to.

2.    On your server, make sure you register the VSIX mime type.  Without this, when customers try download the VSIX file, IE may convert the file extension to .ZIP.  For more information on setting the mime types, check out this article or do a search on Bing :)

Quan To - Program Manager - Visual Studio Platform

Behind the Scenes: The Splash Screen

clip_image002

Paul Harrington – Principal Developer, Visual Studio Shell Team
Short Bio: Paul Harrington is a principal software developer on the Visual Studio platform team. He has worked on every version of Visual Studio .Net to date. Prior to joining the Visual Studio team in 2000, Paul spent six years working on mapping and trip planning software for what is today known as Bing Maps. For Visual Studio 2010, Paul designed and helped write the code that enabled the Visual Studio “Shell” team to move from a native, Windows 32-based implementation to a modern, fully managed presentation layer based on the Windows Presentation Foundation (WPF). Paul holds a masters degree from the University of Cambridge, England and lives with his wife and two cats in Seattle, Washington.

[Editor’s note: The “Behind the Scenes” series is designed to be fun, educational and informative. While some “Behind the Scenes” articles may reveal the inner workings of Visual Studio, the details are subject to change at any time. Unless otherwise noted, you may not rely on this information for developing your own Visual Studio extensions. Please always refer to the documentation on MSDN for public Visual Studio Extensibility APIs]

The first thing people notice when they launch Visual Studio 2010 Beta 2 is the splash screen with the new Visual Studio branding. The infinity symbol been Visual Studio’s logo for over a decade, but for 2010, it has received a makeover. The branding also includes a new “particle wave” element, replacing the connected, rounded rectangles of previous versions.

The Visual Studio 2010 Shell splash screen 

Getting these pixels onto the screen at startup involves some clever coding tricks and this short post reveals what goes on “behind the scenes”.

Performance

The splash screen code has to be fast - as lightweight as possible. This is for two reasons:

1. There must be the shortest delay possible between the action of launching Visual Studio and the splash screen appearing. Otherwise, the user may think that the program isn’t responding and try to launch Visual Studio a second time.

2. At start up, the last thing we want to do is waste precious resources on (what some might call) trivial, transient visuals. While the splash screen is an important piece of UI for establishing brand identity, if it delays the launching of the rest of the IDE, it becomes an annoyance.

Even though Visual Studio 2010 uses WPF for its main window, using WPF for the splash screen would require that we wait for the CLR and WPF to initialize before we could paint a single pixel on the screen. While we’ve made some tremendous improvements in CLR and WPF startup speed in .Net 4.0, it still can’t quite match the performance of raw Win32. So, the choice was made to stay with native C++ code and Win32 for the splash screen.

You may have noticed that the splash screen in Visual Studio 2010 gently fades into view. The fade-in animation actually takes 200 milliseconds which, to a performance engineer, is an eternity. It’s more than 10% of our warm start performance goal. Fortunately, a lot of other things can happen during those 200 milliseconds because the entire splash screen UI is controlled from a background thread. That’s right; at application start, Visual Studio creates a dedicated, low-priority thread, to load the splash screen image and fade it onto the screen. Once the fade-in is done, the thread sticks around until the main window is ready to show, at which point the splash screen window is destroyed and the thread quietly slips into the night.

Behind the Scenes fact #1: If you run Visual Studio 2010 on a computer with a single core, then the splash screen thread is not created. Instead, the main thread picks up all the work. In this case, there is no fade in animation. Instead, the splash screen pops on the screen at full opacity.

Behind the Scenes fact #2: The fade-in animation is also turned off in a remote desktop session to save on network bandwidth.

Alpha Blending

One obvious feature of the new splash screen is the curved bottom edge which mimics the curved profile particle wave graphic. If you look closely, you’ll notice that the image also has rounded top corners and a soft drop shadow. If you have an eye for such things, you may also notice that the curved edges are anti-aliased. The curves, drop-shadow and anti-aliasing are all achieved by adjusting the alpha channel (transparency) of each pixel in the original image. If you already know how alpha blending works you can skip this next paragraph.

Most people know that a pixel’s color on the screen is determined by its Red, Green and Blue component values (RGB). By varying the values of each component or “channel”, any one of millions of different colors can be created. When all channels are off, the result is a black pixel. When all channels are at their maximum intensity, a white pixel is shown. The intensity of each channel is represented by a number where zero means “off” and the maximum value is the maximum intensity possible. So, for example, starting with a black pixel (all channels “off”), gradually increasing the value of the red channel will show a gradually brighter and brighter red pixel. Typically, an 8-bit number (byte) is used to represent the intensity, so the maximum intensity is represented by the number 255. With three channels, 3 bytes (24 bits) are needed to represent all possible colors. Most PCs these days are 32bits, meaning that internal registers and memory work most efficiently when dealing with data that is 32 bits long (a DWORD). If we use a DWORD to represent each pixel, with only 24 bits used for color information, that leaves 8 bits of “wasted” information. Those unused bits on each pixel are just too tempting to ignore, so it didn’t take long before some bright spark came up with a use for those spare bits. The alpha channel uses those 8 bits to represent a “blending” contribution for each pixel – “per-pixel alpha”. When the pixel is painted on the screen, its color contribution is blended with the color of the pixel already on the screen to give the final result. The strength of that contribution is set by the alpha value. An alpha value of zero indicates a fully transparent pixel – one that does not contribute at all to the final image. A fully opaque pixel – one that completely paints over any underlying pixel - is represented by the maximum alpha value of 255. Values of alpha between 0 and 255 represent partial contributions. A higher value of alpha means a stronger contribution of that pixel in the image. So now, instead of just RGB, we have an ARGB (A for Alpha), 32 bits per pixel (32bpp) image.

For the Visual Studio splash screen image (Figure 1, above), the curved edges, the border and the drop shadow are all part of the original artwork, taking advantage of that alpha channel. Where there is a cut-out, the alpha value is set to zero. Where we need soft edges (the drop-shadow, for example), the alpha channel varies from pixel to neighboring pixel. The entire image is stored in PNG format. The PNG format has lossless compression and supports a full 8-bit alpha channel (transparency).

Behind the scenes fact #3: The entire image has been carefully dithered so that the smooth gradients do not turn into bands of color on low-color displays. Typically these color bands are apparent when connected via Remote Desktop with anything less than 24 bits per pixel color fidelity. The dithering reduces the compression ratio of the PNG files, but we decided to trade the extra space for visual fidelity.

The image is decoded from its PNG file format and loaded into memory using GDI+. To blend the image onto the screen, we use a layered window. The key routine is UpdateLayeredWindow which, with the appropriate flags, is able to perform the necessary operations to paint our 32bpp ARGB bitmap onto the screen with per-pixel alpha blending. For all you code junkies, here’s a snippet of source code:

// Blend the given bitmap, hBmp, into a layered window.
BOOL Blend(
    HWND hWnd,      // Must be a layered window
    HBITMAP hBmp,   // The image. Must be 32bpp ARGB format
    BYTE alpha )    // Overall opacity (0=transparent, 255=opaque)
{
    BLENDFUNCTION bf =
    {
        AC_SRC_OVER,    // BlendOp
        0,              // BlendFlags
        alpha,          // SourceConstantAlpha
        AC_SRC_ALPHA    // AlphaFormat
    };

    // Find the image's size in pixels
    BITMAP bm = {};
    if( sizeof(bm) != GetObject(hBmp, sizeof(bm), &bm) ) return FALSE;
    SIZE size = { bm.bmWidth, bm.bmHeight };

    // Create a screen device context and select the image into it.
    HDC hdc = CreateCompatibleDC(NULL);
    if( !hdc ) return FALSE;
    HBITMAP hBmpOld = SelectBitmap(hdc, hBmp);

    // Update the layered window
    POINT ptSrc = { 0, 0 };
    BOOL bRet = UpdateLayeredWindow(
        hWnd,
        NULL /*hdcDst NULL to use the default palette for the screen*/,
        NULL /*pptDst NULL because the position isn't changing */,
        &size,
        hdc,
        &ptSrc,
        RGB(0,0,0),
        &bf,
        ULW_ALPHA );

    // Restore the device context and clean up
    SelectBitmap(hdc, hBmpOld);
    DeleteDC(hdc);

    return bRet;
}

License and Copyright Information

The final image, as below, includes text for the license, legal copyright and pre-release designation - “Beta 2”, in this example.

The Visual Studio 2010 Ultimate Splash Screen with License and Copyright Information

The text is painted onto the base image using GDI+. We chose GDI+ because it supports alpha blending of ClearType anti-aliased text directly into the image as you can see in the following magnification:

clip_image006

What’s interesting about this, is that no text painted at startup. In fact, the text already present in the PNG file. This is a two-fold performance optimization:

1. This is localizable text, so time is saved by not loading localized resources at startup.

2. Loading the necessary fonts and spinning up the GDI+ text rendering code also takes time.

This optimization trick saves time at startup, minimizing the time required to prepare the splash screen. As Figure 1 shows, the text is not in the original base image, so how did it get there?

Behind the scenes fact #4: During Visual Studio setup, the final splash screen image is generated by composing the base image with localized text, rendered via GDI+. The resulting image is saved as a PNG file stored as program data on the user’s machine.

Miscellaneous

If you have a PC with more than one monitor attached, the splash screen will appear centered on the monitor closest to where the main Visual Studio IDE window will appear. This position is saved each time you shut down Visual Studio.

The same display code is used for the regular Visual Studio shell and the Isolated Shell. So, for the first time, you can use full 32bpp ARGB PNG files for your Isolated Shell splash screen.

Conclusion

I hope you’ve enjoyed reading about some of the secrets of the Visual Studio 2010 splash screen. Please leave a comment and let us know what you thought about this blog post and if you have any requests for future editions of “Behind the Scenes”.

Tips and tricks: Window Management – Aero Snapping

Adrian Collier

Adrian Collier – Program Manager, Visual Studio Shell Team
Short Bio: I started at Microsoft as an intern in 2004 back in the UK and crossed the pond last year to work on Popfly, since then I’ve been working in Visual Studio land primarily working on the Start Page and window management areas if the IDE.

 
One of the largest areas of feedback we had from Beta 1 was the lack of Windows 7 Aero Snapping functionality with floating windows; we are very pleased to offer this functionality in Beta 2!

What is Aero Snapping?

Aero Snapping allows you to easily dock windows side-by-side, move a window to another monitor or simply maximize/minimize using a mouse or keyboard gestures. For more information on the Aero Snap feature in Windows check out this these videos.

Screenshot of two windows side by side 

Below are the keyboard shortcuts for interacting with floating VS windows.

Command

Shortcut

 

Notes

Maximize

Windows + Up Arrow

 

Restore

Windows + Down Arrow

 

Minimize – from windowed state.

Windows + Down Arrow

This command only works on the main Visual Studio IDE.

Dock to Screen Left

Windows + Left Arrow

(This command can also be used to cycle through the various docked states across multiple monitors)

Dock to Screen Right

Windows + Right Arrow

(This command can also be used to cycle through the various docked states across multiple monitors)

Expand Height

Windows + Shift + Up Arrow

 

Move Window to 2nd Monitor on left of primary display

Windows + Shift + Left Arrow

 

 

 

Move Window to 2nd Monitor on right of primary display

Windows + Shift + Right Arrow

 

 

 

What about the Aero Shake, can I use this to hide floating VS windows?

Unfortunately, no.  Since all floating windows are “owned” by Visual Studio and cannot be minimized individually, shaking a floating window will only result in minimizing other applications.

We will be following up with more posts on how to become more productive with Visual Studio by taking advantage of shortcuts and less well known Visual Studio features.

Adrian Collier
Program Manager, Visual Studio Shell Team

Improvements to VS 2010 Text Selection

Brittany Behrens Brittany Behrens – Program Manager, Visual Studio Editor Team
Short Bio: I’m Brittany, a Program Manager on the Visual Studio Editor team.  Some of you may recognize me from Connect bugs or as the main voice of @VSEditor on Twitter, and I’m responsible for a variety of Editor features.  I love hearing from customers, so please let me know what you think!

 

As you may have noticed, text selection in Visual Studio 2010 is a bit more colorful than in previous versions.  In VS 2008 and earlier, selected text had a single foreground color and a single background color, usually white text on a navy blue background by default.  However, we have made substantial changes and improvements to the Visual Studio Editor for this release, including the new for VS 2010 ability to compose different display layers together. One of the many benefits of this is that we can combine the background color for selection with the foreground colors for a variety of other display items (plain text, keywords, comments, etc.) to show syntax coloring not only for unselected text but now for selected text as well, which we think makes selected code easier to understand.  Check out this side-by-side comparison to see the difference:

Selection in Visual Studio 2008 vs. Visual Studio 2010

In light of this new mini-feature, we intentionally disabled the foreground color option for Selected Text in Tools->Options->Environment->Fonts and Colors.  Because selected text doesn’t have a single foreground color but instead retains whatever syntax coloring it had when not selected, an option for selected text foreground color doesn’t make sense for Visual Studio 2010.  For Beta2, the Tools->Options preview for Selected Text always shows the VS 2008-style white foreground color, which we realize can be confusing.  We’ve already updated this internally so that for VS 2010 RTM, the Item Foreground Color dropdown and the Sample preview box will show your default Plain Text foreground color instead of white, giving you a more accurate idea of what selected text will look like in the editor.

This is one of many improvements we were able to make by moving the editor to WPF – hope you enjoy it!

Brittany Behrens
Program Manager, Visual Studio Editor Team

Send Us Your Feedback: Visual Studio 2010 Beta 2 Survey!

wespic

Weston Hutchins – Program Manager, Visual Studio Shell Team
Short Bio: I started at Microsoft as an intern in 2005 and have been working in Visual Studio ever since.  I’m currently a PM on the VS Shell Team.  No, not the “Isolated” or “Integrated” Shell, but the core VS IDE – it’s UI and services.  Prior to my current duties, I was the SKU manager for the Visual Studio Express products. Outside of work, I’m an avid football fan, love winter sports, and always enjoy some quality mac and cheese.

I know this has already been mentioned on some notable blogs, but I wanted to add the VS Platform Team’s word of encouragement to take a few minutes and fill out the Beta 2 survey

image_3

Your real-world experiences will help us track down the remaining areas of focus before we ship in March.  So, please let us know what you think about the new UI, the WPF-based editor and its extensibility, the C++ MSBuild project system, the VSIX deployment enhancements and anything else that you like or dislike about the product.  The more specific you can be the better.  Even though we cannot act on everything, it’s important for us to understand how our customers are using and reacting to Visual Studio 2010 Beta 2.  So, please keep it coming!

How to Fix “The application cannot start” Error

wespic

Weston Hutchins – Program Manager, Visual Studio Shell Team
Short Bio: I started at Microsoft as an intern in 2005 and have been working in Visual Studio ever since.  I’m currently a PM on the VS Shell Team.  No, not the “Isolated” or “Integrated” Shell, but the core VS IDE – it’s UI and services.  Prior to my current duties, I was the SKU manager for the Visual Studio Express products. Outside of work, I’m an avid football fan, love winter sports, and always enjoy some quality mac and cheese.

Introduction
So, you’re sitting on your couch and all of sudden…epiphany!  You’ve got the solution to the code problem you’ve been working on for a few days!  You go to fire up Visual Studio, and instead of being treated with a new instance of VS you are presented with this -- the dreaded error: “The application cannot start.”:

image
“Well, it was working fine this morning!” you say.  “What happened!?”

I wish I had a quick, easy, one-line answer for why this happens, but as with most things in life, it isn’t that simple.  There are a number of scenarios that will cause the IDE to get into this state, which makes diagnosing this issue rather non-trivial.  When Visual Studio is launched, the initialization code branches off and begins to perform a number of tasks such as reading the window layout, importing the saved settings, loading a number of .dlls, creating the main window, etc.  If any one of these operations encounters a critical exception from which it cannot recover (which means VS won’t be able to initialize properly), an error is raised and the user is presented with “The application cannot start.”

Now, you may be asking, “Well the least you could do is give me some exception message that would make debugging this easier, right?”  Unfortunately, no.  Because of the managed to native interop on the initialization thread, all the code gets back is an HRESULT; it loses its error context.  There are a few alternative approaches that we are investigating for RTM around providing a more meaningful error message.

Now that I’ve given you the background, what do you do if you hit this?  We’ll start with the most common case, at least for Visual Studio 2010 Beta 2.

The Issue
In Visual Studio 2010 Beta 2, there are two straightforward ways to get into this state.  Both of these issues have been fixed for RTM, and, fortunately, there are workarounds for Beta 2.

  1. The first issue is importing a non-TrueType font from a previous version of Visual Studio.  This was already covered by Brittany in her excellent blog post.
  2. The second way to get in this state is by a corrupted window profile – the file that persists your IDE window state.  If you have floating tool windows (e.g., drag off Solution Explorer to another monitor or show the Find dialog), minimize Visual Studio, and then close Visual Studio from the minimized state, on the next launch you will hit this error. 

The Workaround
To workaround these issues, you’ll need to reset your settings file.  NOTE: The IDE will be reset to its default state and all customizations will be lost.  If you have customizations that you want to save, please copy CurrentSettings.vssettings under “%USERPROFILE%\Documents\Visual Studio 2010\Settings” to another location. 

If you’re using a non-Express SKU:

  1. Start Menu->Run (or Windows Key + R for the keyboard savvy)
  2. Type “devenv /resetuserdata”.  The issue should now be fixed.
  3. If you wish to reimport your old settings, go to Tools->Import and Export Settings, select “Import selected environment settings and browse to the .vssettings file you saved.

If you’re using an Express SKU your steps will be a bit different:

  1. Start Menu->Run (or Windows Key + R for the keyboard savvy)
  2. Depending on the SKU installed, type the following:
    • For Visual Basic Express type, “vbexpress /resetuserdata
    • For Visual C# Express type, “vcsexpress /resetuserdata
    • For Visual C++ Express type, “vcexpress /resetuserdata
    • For Visual Wed Developer Express type, “vwdexpress /resetuserdata

What we’ve done for RTM
As mentioned above, both these issues have been fixed for RTM.  Additionally, we’ve also added better fallback scenarios so that if something does go wrong, the IDE will try a few workarounds itself.

What if that didn’t fix the problem?
The above workaround should fix the majority of users that run into this issue, but if you’ve tried that to no avail, here are a few other things you can try:

  • Browse this MSDN article.  This article is a bit outdated but does have some other causes and workarounds for fixing this issue.
  • Some users have had success using procmon to see what Visual Studio is trying to load.  This isn’t for the faint-hearted, but it might help you debug the issue.
  • Analyze the Activity Log.  Sara Ford has a post on how to do this

If your still experiencing problems, the best option is to file a Connect Bug so that we can take a further look.  To help us debug, please attach the following files to the bug:

  1. Your window layout file: the file will be named “Design_somecharacters.winprf” under “%APPDATA%\Microsoft\VisualStudio\10.0
  2. Your settings file: “CurrentSettings.vssettings” under “%USERPROFILE%\Documents\Visual Studio 2010\Settings
  3. Your Activity log: From a Visual Studio Command Prompt, type “devenv /log”.  Attach “%APPDATA%\Microsoft\VisualStudio\10.0\ActivityLog.xml” to the bug.

Happy coding!

Weston Hutchins
Program Manager – Visual Studio Shell Team

FIXED: Comments are not getting posted

Update: We have diagnosed and fixed the issue that was causing comments to be discarded.  If you were trying to post a comment in the last few days, we'd appreciate it if you could repost -- we love to hear feedback.  If you are having any more issues with your comments appearing on the blog, please send a mail to vsblog AT microsoft DOT com. 

We're currently experiencing issues regarding our comment system, and if you post a comment it may not appear on the blog.  It's unclear whether the comments are getting discarded or are stored somewhere where we can't access them.  We are investigating the issue ASAP and I will let you know when it has been fixed.  Sorry for the inconvenience.

Thanks,
Weston Hutchins
Program Manager - VS Platform

VS 2010 Beta2: Workaround for Raster Font Settings Issue

In addition to making announcements, showcasing features, posting walkthroughs, and sharing Visual Studio tips and tricks, we’ll also be using this blog to raise awareness of commonly-encountered bugs and explain their workarounds.  As many of you know, we’ve rebuilt the editor using WPF for Visual Studio 2010.  This allows for a wealth of new visualizations and enables many new extensibility scenarios, often making previously impossible tasks possible and previously difficult tasks much easier.  However, because WPF renders only TrueType fonts, it also means that the Visual Studio editor no longer supports raster or bitmap fonts.

The Bug:
Attempting to use a non-TrueType font in Visual Studio 2010 Beta2 throws an exception when opening a file, usually with the message “Object reference not set to an instance of an object.”  The editor will not load.

The Workaround:
In Tools->Options->Environment->Fonts and Colors, change any raster or bitmap font settings to a TrueType font, or simply click OK to have any raster fonts fall back to the default font (Consolas on English systems).  The editor should then load correctly.

Fix Status:
Already fixed for Visual Studio 2010 RTM.

The most common way to encounter this bug is to import settings that include a non-TrueType font from a previous version of Visual Studio.  Running "devenv /resetuserdata" will also resolve the issue, though it will reset all of your settings to the defaults and therefore change more of your preferences than is necessary to fix the problem.  This bug has already been fixed for VS 2010 RTM, where importing or selecting a non-TrueType font will cause the editor to fall back to the default font (Consolas on English systems) and load successfully instead of throwing an exception.

We also discovered that although most bitmap fonts were removed from the default Fonts and Colors list, we inadvertently missed a few.  They are:  Courier, Fixedsys, Modern, MS Sans Serif, MS Serif, Roman, Script, Small Fonts, System, and Terminal.  These fonts have already been removed from the default list for VS 2010 RTM.

Again, this is a bug in Visual Studio Beta2 that has already been fixed internally for VS 2010 RTM.  If you have any questions about this bug or its workaround, please feel free to post a comment below and we’ll do our best to help.

Thanks for trying Visual Studio 2010 Beta2!

Brittany Behrens
Program Manager, Visual Studio Editor Team

VSIX and MSI

VSIX is a new technology created for deploying Visual Studio extensions.  It’s a zip file that uses the Open Packaging Convention.  By renaming the file extension of any .VSIX file to .ZIP, you can open up the file in Windows Explorer and take a look at the contents.

I’ve written a separate post about the details of a VSIX and one of our MVPs, Istvan Novak and I gave a talk at the VSX Developer’s Conference last week about general extension deployment.  Istvan was gracious enough to post the transcript of our talk.

After the talk, several VSX partners asked me to go into more details on how they can deploy their extensions using an MSI but still play in the VSIX space and show up in the Extension Manager.

Our recommendation is to ship your product as a VSIX but we understand there are limitations preventing you from doing that such as legacy requirements to support older tools that expect files to be in a specific location, configuring an IIS server or Database on install, or supporting VS 2005, 2008 and 2010 all within a single installer.

If you have to use an MSI, we want to make sure the MSI gets the exposure it needs and plays nicely with the Extension Manager.  Here are some tips to follow to ensure that:

  1. Create an extension.vsixmanifest and add it to your MSI.  To create a manifest file, take an existing file from another VSIX or install the Visual Studio SDK and create a new VS extension.  When you build the extension, the extension.vsixmanifest is created for you.
  2. In the ID section of the manifest, add the following tag:

<InstalledByMsi>True</InstalledByMsi>

Adding this tag will tell the Extension Manager that the extension came from an MSI and not to allow the user to enable, disable, or uninstall it through the Extension Manager, since that could cause problems with the other files still installed via the MSI.

3.   If you have any registry keys that get written under the Visual Studio registry have, create a .pkgdef file instead of using the MSI to write the registry keys for you.  To create a pkgdef file, create a tool window or menu command using the Visual Studio Integration Package template.  Use that as an example pkgdef file to include in your MSI.

4.   Drop your files under %VSInstallDir%\Common7\Ide\Extensions\Your Company\Your Product\Version.  Use a registry look up under HK:LM\Software\Microsoft\VisualStudio\10.0\Setup to find the install path of Visual Studio and substitute that with %VSInstallDir%. (Check out MSI Registry look up for more information if you need to create one).

By following these best practices, your customer can still get a great extension experience and see your extension in the Extension Manager.

You can also upload your MSI to the Visual Studio Gallery and have it appear in the online tab of the Extension Manager.

Happy Deploying!

Quan To | Program Manager | Visual Studio Platform

Box Selection and Multi-Line Editing

clip_image002I’m Brittany, a Program Manager on the Visual Studio Editor team.  Some of you may recognize me from Connect bugs, @VSEditor on Twitter, or the Visual Studio Editor blog, which has recently moved to its new home here at The Visual Studio Blog.  I’m responsible for a variety of Editor features, but most recently I designed the new-for-VS 2010 multi-line editing functionality in this post and video.

Box selection is back and better than ever for Visual Studio 2010 Beta2!  You can of course make, copy/paste, drag/drop, and delete box selections, just as in VS 2008.  But that’s not all.  For the first time, you can also insert and edit text on multiple lines.  Check out this video we’ve created to demo the new Box Selection and Multi-Line Editing functionality (this demo has video and audio, so plug in your headphones or turn up the sound):

We’ve also made a few changes to box selection that didn’t quite make it into Beta2:

  • In Beta2, indenting a box selection will indent the entire lines containing that box selection.  We have since changed it to indent only the box-selected text, which matches VS 2008 behavior.
  • In Beta2, pasting a box selection on a blank line will interleave the box-selected text with existing text.  We have since changed it to paste the box selection with newlines instead of interleaving, which matches VS 2008 behavior.

This is box selection’s first appearance in VS 2010 and multi-line editing’s Visual Studio debut, so we’d love to hear your feedback!  You can use any of several ways to share your thoughts, either about box selection or regarding other aspects of the Beta2 editor experience:

Whichever method you choose, I hope you’ll let us know what you think!

Brittany Behrens
Program Manager, Visual Studio Editor Team

Toolbox Search

me_small Hi, my name’s Josh and I’m a developer on the VS Shell team.  Among other things, I’m responsible for the Toolbox.  In VS 2010 Beta2, we’ve added the ability to search for controls in the toolbox by name.  To use it, put focus in the toolbox (by clicking in it, for example) and start typing the name of the control you want to find.  As you type, the selection will move to the next item that matches what you've typed so far.  The text you've typed is shown in the status bar, like this:

toolbox_search

You can hit Backspace if you mistyped a character, or Tab to go to the next match for the current string.  To cancel the search, you can hit Escape, move the selection, or click on another window.

Visual Studio Sessions at PDC ‘09

The Professional Developers Conference (PDC) this year is in Los Angeles from November 17th to 19th. The PDC is an opportunity to mingle with architects and developers from the software industry and to listen to the leaders, heroes and legends from Microsoft and its industry partners. As well as workshops and training sessions, there are hands on labs, a product pavilion and “ask the experts” Q&A discussions. This year’s keynote speakers are Ray Ozzie and Bob Muglia. Joining them on stage will be Kurt DelBene and Scott Guthrie.

clip_image002A few days prior to the Windows 7 launch last week, we announced the general availability of Visual Studio 2010 Beta 2. So, by the start of the PDC attendees will have had four weeks to try it out and explore its capabilities. Many of the sessions at PDC this year will showcase Visual Studio’s wealth of new features: Azure tooling for the cloud, Silverlight for the web, parallel tools for scalable concurrency, new debugging tools such as IntelliTrace, tools for Microsoft Office such as SharePoint Server, and that’s just the start; the list goes on.

One of the sessions I’d like to announce here is being given by the Visual Studio Platform team’s very own Paul Harrington. Paul was invited by the Windows Presentation Foundation (WPF) team to present a session entitled “How Microsoft Visual Studio 2010 Was Built with WPF 4”. For Visual Studio 2010, Paul led the feature crew which took the existing Visual Studio 2008 IDE and converted it to managed code with WPF. In the session Paul will explain how this feat was accomplished and talk about some of the obstacles they had to overcome along the way.

We’re incredibly proud of the results of this work, not only in Visual Studio 2010 itself, but also in the improvements that the Visual Studio Platform team helped make in WPF 4. Those improvements, bug fixes, new features and performance tweaks will make it easier and faster for others to develop world-class software using WPF.

More Posts Next page »
Page view tracker