Visual Studio 11 IDE Improvements

This is second post of the Dev11 series. If you have not installed preview bits, you may like to read my previous post on “Visual Studio 11 Developer Preview”. In this post, I am going to share some of the improvements in Visual Studio 11 IDE.

//Disclaimer #1: This post is written for Developer Preview version, and features may change in later releases.
//Disclaimer #2: The views expressed in this post are mine alone neither of my employer nor of Microsoft.
//Disclaimer #3: This is a long post

The Visual Studio 11 IDE contains bunch of improvements/enhancements and some of them are modified/enhanced version of Productivity Power Tools extension available for Visual Studio 2010 which you might be familiar with. The reason I am really excited about this release is because, for the last two years, I have been involved in providing feedback to Visual Studio team as part of technical community and so one of the thing we discussed during MVP Summit was that Visual studio has lots of options, commands, windows etc. that are not known to developers and therefore it is important for developers productivity and experience to consolidate features and make them discoverable. I really think the VS team have done well in considering community feedback. So let’s discuss some of the improvements:

Solution Explorer

If you compare Solution Explorer of Visual Studio 2010 with Visual Studio 11, it has really improved a lot.

Solution Explorer in VS 2010 and VS 11

Solution Explorer - Browsing CodeNow you can utilize solution explorer for browsing types, type members, search symbols and find relationships among them. Thank God they have provided collapse button in Solution explorer… at times it was quite irritating to collapse projects etc.

You can now Browse Code within solution explorer, by expanding down types and type members. This helps in quickly jumping to a particular type member such as property or method. It further gives option to view call hierarchy (Calls, Is Called By, Is Used By) of a method via context menu.

  • Calls – display list of methods called by the selected method
  • Is Called By – display list of methods that calls selected method
  • Is Used by – display list of methods using selected method in line, similar to Find All References option

A great thing I have observed is when I have a large solution and I try to browse to type members level, the visual studio lazy loads the type members and populate the items which I believe must be adding value in terms of performance.

Solution Explorer - (Method) [Calls]Solution Explorer - (Method) [Is Called By]Solution Explorer - (Method) [Is Used By]

Searching symbols in solution explorer made it easy to find any class, methods, properties, in fact any symbol in code. For example, following image depicts the search result of ‘Mock’. You can also use (Ctrl+;) as shortcut to search using solution explorer. This is small but very beneficial feature for developers to quickly search for what they are looking for in code.

SolExpSearch

Finally the search results in Solution explorer can be viewed with single click on any item of the result list instead of double clicking class etc. which really allow developers to quickly jump between search results.

Quick Launch

Quick launch is one of the great features of this version. How many of you actually feel that it’s difficult to find options, commands etc. in Visual Studio? How many of you felt like forgetting a menu option? How many of you felt like it takes time to navigate through menus like Tools –> Options –> Debugging etc.? How many of you felt its annoying to remember shortcuts?

The Visual Studio 11 has answer for you in the form of “Quick Launch”. Quick Launch option is available on top right corner of Visual Studio or using shortcut key (Ctrl+`).

QuickLaunch

For example, I want to look for the option of formatting code or document or any other option related to format. Quick Launch allows me to simply search for ‘Format’ and it will show me all the commands and options related to that as shown below:

Quick Launch - Result

So this really gives me a quick way to search all the options related to Formatting instead of going through menus, especially if you don’t remember the shortcut.

Simplified Toolbars

You probably have notice that toolbar is single row with fewer, yet frequently used, options.

Visual Studio 11 - Toolbar 

This is because it has been observed that most of the developers tend to utilize only some of the commands in toolbar. For example, developers don’t use commands like Cut, Copy, Paste, Save and some other options from toolbar… they usually do it using shortcuts or don’t use them. So based on feedback and research, it has been simplified to most frequently used commands only. With toolbar consuming less space, now you have more SPACE for editor!

Concluding Remarks

That is all for this post, hope you enjoyed reading about the IDE improvements in Dev11. The Visual Studio 11 IDE contains bunch of other enhancements as well which I would love you share, hopefully in coming post.

Until next time, Happy Coding!

Visual Studio 11 Dev Preview

Like me, if you work on .NET platform and Visual Studio, you must be excited about the recent announcements of “Visual Studio 11 Developer Preview” or “Dev 11” at BUILD conference on September, 14, 2011. The next version of Visual Studio and .NET framework contains many new features and enhancements, making job of .NET developer easy.

Over the next few weeks, I am going to write series of posts on some of the new features and enhancements in Visual Studio IDE, C# and .NET Framework 4.5.

Getting Started:

To begin with, you can download Visual Studio 11 Developer Preview:

  • For MSDN Subscribers – link
  • For Everyone else – link
  • For ASP.NET Developers, download ASP.NET MVC 4 Preview for VS 2010 or VS 11 – link

If you have missed BUILD conference online, following are some of the overview talks related to Dev Tools:

Keynote # 2

Whats New in Visual Studio 11

Future Directions for C# and Visual BasicWhat's new in .NET Framework 4.5

Installation:

I have installed Visual Studio 11 Developer Preview on my home machine side by side with Visual Studio 2010 on Windows 7. It seems to be working fine and installation was successful. I am not sure about proper uninstallation when I will go for beta later 😉

I downloaded the .ISO file as MSDN subscriber. Following are the snapshots for Setup.

Step 1Step 2Step 3

Step 4Step 5Step 6

For ASP.NET MVC 4 Preview, as mentioned, you need to download it separately either via Web Platform Installer for Visual Studio 2010 or Visual Studio 11 Dev Preview or directly from installer. I did it using Web Platform Installer for Visual Studio 11. Following are the snapshots for setting up ASP.NET MVC 4 Preview:

ASP.NET MVC 4 Installer (Visual Studio 11)ASP.NET MVC 4 Installer (Visual Studio 11) - prerequisites

ASP.NET MVC 4 Installer (Visual Studio 11) - InstallASP.NET MVC 4 Installer (Visual Studio 11) - Finish

Concluding Thoughts 

I am all done with setting up Visual Studio 11 Developer Preview and ASP.NET MVC 4 Preview. I am excited to see the implementation of some of the important community feedbacks we have provided to Visual Studio team over the time. So go ahead and download the bits if you have not done it yet. Coming up next is IDE Enhancements in Visual Studio 11, stay tuned!

Configuring ELMAH with WCF using NuGet

I am sure most of you have used Error Logging Module and Handlers (ELMAH) for ASP.NET. ELMAH is one great open source project and real blessings for ASP.NET developers. If you don’t know about it, It’s a MUST SEE tool and in that case I would recommend you to read out Scott Ha introductory blog post on ELMAH.

BUT, in this post we are going to see how to configure ELMAH to work with WCF services because if you do that in a typical way then ELMAH is probably not going to work as expected and it won’t show you any unhandled exception.

So let’s get started!

ElmahWithWcfSolution

I have created a new WCF Application project ElmahWithWcf containing one contract IDemoService and service implementation class DemoService.

To add ELMAH, you can either download it from project host site and configure it or you can simply use NuGet to download and automatically install/configure ELMAH.

NuGet is a Visual Studio extension that makes it easy to install and update open source libraries and tools in Visual Studio. Perhaps it really does simplify the life of developer when it comes to configure third party open source libraries. If you haven’t used NuGet, I would strongly encourage you to install it from Visual Studio Extension Manager (Tools –> Extension Manager). It’s free. You can also read NuGet documentation on CodePlex.com for further help or ping me back.

Once you have installed it, you can Add/Configure ELMAH via “Add Library Package Reference” in context menu of references folder.

In Add Library Package Reference, search elmah in online packages and click install, which will automatically download the required assemblies and configure entries in web.config as well. Isn’t it cool?

Add Library Package Reference

Just in case if you don’t believe, with NuGet you get all the config entries automatically!!!

Config Entries by NuGet

With this ELMAH is now configured as you would typically do in ASP.NET web application, however, in contrast to ASP.NET app, it won’t log any unhandled exception that is raised in WCF service. For this, to work correctly, you need to create custom Error Handler implementing IErrorHandler as demonstrated in code snippet below:

public class ElmahErrorHandler: IErrorHandler 
{
    #region IErrorHandler Members
    
    public bool HandleError(Exception error) 
    {
        return false;
    }
    public void ProvideFault(Exception error, MessageVersion version, ref Message fault) 
    {
        if (error == null) 
        {
            return;
        }
   
        if (HttpContext.Current == null) 
        {
            return;
        }
   
        Elmah.ErrorSignal.FromCurrentContext().Raise(error);
    }
  
    #endregion
 }
 
 //Further in addition to that, you need to create a Service Behavior Attribute implementing Attribute and IServiceBehavior 

  public class ServiceErrorBehaviorAttribute: Attribute, IServiceBehavior 
  {
    private readonly Type errorHandlerType;
    public ServiceErrorBehaviorAttribute(Type errorHandlerType) 
    {
        this.errorHandlerType = errorHandlerType;
    }
    
    #region IServiceBehavior Members 
    public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection < ServiceEndpoint > endpoints, BindingParameterCollection bindingParameters) 
    {
    }
    
    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) 
    {
        IErrorHandler errorHandler;
        errorHandler = Activator.CreateInstance(errorHandlerType) as IErrorHandler;
        if (errorHandler != null) 
        {
            foreach(ChannelDispatcherBase dispatcher in serviceHostBase.ChannelDispatchers) 
            {
                ChannelDispatcher cd = dispatcher as ChannelDispatcher;
                cd.ErrorHandlers.Add(errorHandler);
            }
        }
    } 
  
    public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) 
    {    
    }
    
    #endregion
 } 
 
 //And finally you need to apply the custom attribute on your service implementation class   
 [ServiceErrorBehavior(typeof(ElmahErrorHandler))]
 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
 public class DemoService: IDemoService 
 {
     #region IDemoService Members 
     public string GetData(int value) 
     {
        throw new Exception("TEST");
        return string.Format("You entered: {0}", value);
    }
    
    #endregion
 }

That is all you need to do for ELMAH to work with WCF.

 

At this point, ELMAH must show all unhandled exception in log file. For example, line number 9 throws an exception with message “Test”. If we invoke the service method, the ELMAH should log this exception. The log file can be browsed at http://ServerPath/elmah.axd

In fact, ELMAH is so convenient that we decided not to use Enterprise Library Logging Block and utilized ELMAH to log even handled exception as well (Yes another reason was timelines as well).

Did I hear How? Well, in that case you simply need to manually add one line in catch block.

image

This will inform/raise about the exception to ELMAH and so it will log the handled exception as well.

Hope this Helps!

In case of any feedback/experience, please do share…

Happy Coding!

Event Summary: Visual Studio 2010 Ultimate LoadFest

Reference: http://edotnetdevs.wordpress.com/2010/12/04/event-summary-visual-studio-2010-ultimate-loadfest/

Visual Studio 2010

THANK YOU FOR ATTENDING VISUAL STUDIO 2010 ULTIMATE LOADFEST!

4th December 2010, we had another exciting event “Visual Studio 2010 Ultimate LoadFest”. The event was held at FAST- National University of Computer and Emerging Sciences, Karachi. We would like to thank all the organizers, speakers, participants and volunteers for making this event successful. Especially to our speakers Adil Ahmed Mughal, Jibran Jamshed and Munir Usman for their valuable time and attention to this event.

Agenda:

  • What’s New in Visual Studio 2010 Ultimate? by Adil Mughal
  • Application Life cycle Management (ALM) by Jibran Jamshed
  • Refreshment
  • Mastering Debugging in Visual Studio 2010 by Munir Usman
  • Lucky Draw [Visual Studio 2010 Ultimate with MSDN Subscription, Pluralsight subscription, Microsoft Bag]

    Adil on New IDE ImprovementsThe first session focused more on the new features in Visual Studio 2010 IDE. The speaker started discussion on the New Project Dialog improvements and Start Page customization in Visual Studio 2010 then moving towards Core IDE improvements that includes WPF based editor, easy code navigation, improved IntelliSense, column selection, call hierarchy etc.

    Adil then talked about how Visual Studio supports “Test Driven Development” and Code Focused development approach. Then ASP.NET improvements such as ASP.NET/HTML mark up snippets, Cleaner HTML, automatic HTML encoding were discussed. Finally, Visual Studio Extensibility (VSX) was discussed and some powerful/highly rated extensions such as Productivity Power Tools, Power commands etc were demonstrated to the audience.

    Jibran on ALMThe second session was about application life cycle management with major focus on Team Foundation Server 2010.

    Jibran highlighted the issues faced by software development teams in the overall application life cycle and how Team Foundation Server (TFS), along with its numerous features and integration with other tools, can address those issues. He also demonstrated creating new team projects, selecting MSF process, code version control, work items and test cases execution against those work items in Visual Studio 2010 Ultimate and TFS.

    Munir on Debugging in Visual StudioThe third session was on mastering debugging in Visual Studio 2010. The speaker started discussion from basic debugging, such as usage of debugging points, stack trace, immediate window etc, to advance debugging features offered by Visual Studio such as conditional debugging, hit count, filter, macros, data tips, debug labels etc.

    In the end the Munir talked about the historical debugger (IntelliTrace) in VS 2010 ultimate and demonstrated how useful this feature is for developers.

    In the end goodies were distributed via lucky draw. Following were the winners:

    • Sheeraz Sheikh – Winner of Visual Studio 2010 Ultimate with MSDN subscription
    • Winner of Visual Studio 2010 Ultimate with MSDN subscription
    • Fahad Khan – Winner of 1 Month of free training of Pluralsight on-demand
    • Hassan Zahid – Winner of 1 Month of free training of Pluralsight on-demand

    Adil & Munir - Lucky Draw MVP Bag SpottedVS LoadFestVisual Studio Pamphlet

    For more picture, please visit photo album on Emerging .NET Devs Facebook Page. If you have attended the event, please take out few minutes to fill the feedback form here.

    In the end, we would like to thank our sponsors without them it would not be possible to organize this event. INETA, Wrox, Pluralsight, DevNext, Fast.NET

    Sponsors

    Visual Studio 2010 Ultimate LoadFest

    I will be speaking at Visual Studio 2010 Ultimate LoadFest. Registration is open currently and is free but seats are limited. Register yourself now!

    loadfest

    Some more fun with Visual Studio 2010 – Part II

    In last post we saw few good enhancements in VS 2010. In this post we will explore some exciting new capabilities for Architects in Visual Studio 2010 Ultimate.

    If you are using Visual Studio 2010 Ultimate, you will notice Architecture Menu on top. This menu gives architects plenty of options, from modeling their solutions to generating dependencies among your existing projects and the best part of it is that it allows you to even validate your code based on model diagram (H). BUT! for today! We will cover “Generate Dependency Graph” feature in this post.

    The primary advantage of generating dependency graph is to visualize your existing software. This is particularly important in scenarios where you are working in an existing software and want to dig dependencies among assemblies/namespaces/classes etc. We know one thing that software are becoming more complex with time and therefore we need better tools and technologies to understand those complex software solutions.

    So lets go ahead and give this feature a try!

    If we select the option of Generate Dependency Graph –> By Assembly, after few seconds of processing it will show you some kind of web 🙂

    dependency graph

    The lines depicts the dependency of one assembly to another and the bold lines shows higher number of references or more dependency on other assembly. You can also expand or collapse these assemblies. Interestingly if you double click on any line (representing reference and dependency), It will gives you further option to select the level of detail between two assemblies as shown in image below:

    If we select to include Assemblies and Methods , then it will show detail level diagram with assembly containing Methods and their dependency on other assembly’s methods. Cool isn’t it? 🙂

    So if you are working on an existing software and you want to understand the code and interaction of different projects and classes, this feature is a real blessing for you 🙂

    Some more fun with Visual Studio 2010

    Last time we saw some new capabilities in VS 2010 due to the new WPF editor. We also saw about extensions in VS 2010. So let’s explore some more features of Visual Studio 2010, just for fun 🙂

    One ordinary extension that you may like is Visual Studio Color Theme Editor. You can download this extension from Extension Manager (Tools –> Extension Manager). You can search it from online gallery.

     

    Once you download and install it, VS will prompt you to restart and after that you will notice a Theme item in menu bar. What this extension allows you to do is to change the theme of Visual Studio either by selecting one of the pre-defined theme or customizing on your own one 🙂

    I know, as a developer, you may not really care for Visual Studio colors 😉 but guess what? I want to share another feature with you, which I believe many people do not utilize really and that is Line Numbers in Text Editor. By default, Line numbers are not visible in your text editor. You can turn them on by selecting the option of Line Numbers in Option Window (Tools –> Options) as depict below:

    Enabling Line numbers will help you in tracking especially when you refer to errors on particular line number in Error List Window.

    Another great feature of VS 2010 IDE is the Call Hierarchy through which you can visualize all calls to and from a selected method. To view Call Hierarchy, Right click on a method or property and select “View Call Hierarchy” item.

    Not only it shows all the methods and properties that Calls To and From the selected method but it also shows further options when you right click on any of the node such as “Go to Definition” etc.

    This feature is really remarkable from the programmers’ perspective and I hope you will like it too!

    That’s all for now. Have a great day!

    WPF Editor in Visual Studio 2010

    One of the feature of Visual Studio 2010 that I’m excited about is the revamped editor built on top of Windows Presentation Foundation (WPF). For those who have worked on WPF knows that it is a very powerful and flexible platform and that is the reason why I’m excited about it because not only this introduce some good features in Visual Studio but it opens bunch of opportunities for future as well. And I am sure the next version of VS plus VS extensions will provide excellent features for application developers.
    Further to extend editor features, now you don’t have to write VSPackage, instead you can use Managed Extensibility Framework (MEF). For more details, visit Visual Studio on MSDN.
    So the one of the simple feature I like is of Zoom in and out 🙂 and that’s because while presenting on several events I need to increase the font or use magnifier but now I can just zoom in and zoom out using Ctrl + Mouse Scroll Up/down. So now I don’t have to do that
    Zoom in code Zoom out code
    Zoom in to 177% Zoom out to 61%
    Zoom
    Also you will notice in the picture above that now on the bottom left of editor there is option to select zoom level from where you can also change the zooming factor.
    Another feature I would like to mention here is the integration of Visual Studio extensions through Extension Manager. You will find Extension Manager in Tools –> Extension Manager
    VS 2010 Extension Manager
    And what it does is that it connects with Extension Gallery on MSDN and allows you to search and download any extension that is available for Visual Studio including controls, templates etc. Some of them are free, some of them are shareware. So let’s go ahead and search one of the extension. As an example I have searched and downloaded “Image Insertion” extension. After download, Visual Studio will prompt you to restart to take effects. What this extension allows me to do is that drag and drop any image on the code as the screenshots depict below:
    Image Insertion Extension
    Insert Image in Code

    Therefore as an example, I have inserted class diagram just where my class begins to help developer understand what the class does and the methods/properties in it. What you can also do this insert an image which describes the working visually or some UML diagram to help developer in understanding code.

    That is all for today! I hope if you have not gone through the zoom and extension manager features, you will definitely love this post 🙂

    Happy Coding!

    Visual Studio 2010 Professional is FREE for Students

    Good News! The Microsoft recently released development IDE Visual Studio 2010 is available free for students at DreamSpark.

    DreamSpark site

    If you belong to any University in Pakistan and are not registered at DreamSpark. You can submit your registration request here.

    Visual Studio 2010 and .NET 4 is now available

    VS 2010 Life runs on code

    Today, 12th April 2010, Microsoft announced the Visual Studio 2010 RTM and .NET 4 at the VS 2010 Global Launch conference and expo. You can watch the live event at link here. You can also follow the hash tag #VS2010 on twitter to get update about the event.

    The Visual Studio 2010 is now available to download for MSDN Subscribers.