Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Debugging Parallel Code in Visual Studio

.NET 4.0 introduced the Task Parallel Library (TPL) and Parallel LINQ (PLINQ) in an attempt to make parallel programming simpler and making best use of multi-core processors easier.

Recently I was playing around with the Parallel.Foreach and the new Enumerator APIs for the File System in System.IO trying to build a Fast Folder Scanner when I chanced upon the Parallel debugging options in Visual Studio. After fiddling around a little bit, I was able to make sense of the information and it was kind of a ‘brain explode’ moment.

Let me share the things that I figured out.

The Harness Code

- Let’s create a Console Application called FastFolderScanner

- Next we put together the following code to scan folders for a particular type of file and split them out.

New HTML Web Editor Features in Visual Studio 2013

In this article, we will take a closer look at the new web editor features for HTML. You can download Visual Studio 2013 trial edition using this link –

http://www.microsoft.com/visualstudio/eng/downloads

Let’s first start with Visual Studio 2013 and create a new ASP.NET Web Application by choosing .NET Framework 4.5.1 as shown below –

creproj

Some Visual Studio 2013 IDE Enhancements

Visual Studio 2013 builds on the powerful tools and services delivered in Visual Studio 2012 and helps you create a new modern applications. As of this writing Visual Studio 2013 is in RC although this article is based on the Preview Release. You can download Visual Studio 2013 Preview to test the IDE enhancements and new features.

1. Assuming you have downloaded and installed Visual Studio 2013, launch Visual Studio and you will see the first screen which is a Sign in screen as shown below

Advanced Code Search in Visual Studio using Sando

This article was Guest blogged by David Shepherd and is intended to give information about a free code search tool extension in Visual Studio.

For large projects, new developers can take weeks or even months to become productive contributors. To acclimate them to their new project, team leads often start developers off with bug fixing or smaller tasks. In this scenario, new developers find themselves staring at thousands of lines of code, completely lost as to how to begin. Fortunately, a new set of tools is quietly becoming available that accelerates the learning process. This post will detail how to use the features of next-generation FindInFiles tools, such as query recommendations, instant search, and quick review workflow, to avoid the common problems that new developers face.

NuGet – The Visual Studio Sweetner

Recently we saw some new features in Visual Studio 2012 for a Web Developer. One feature we didn’t touch upon was Nuget! NuGet per-se is not a new feature and it’s been around for a couple of years now. However, no Visual Studio article is complete without a mention of Nuget. So we decided to follow up with an article specially dedicated to NuGet .

This article has been co-authored by me and Suprotim Agarwal

I have been a NuGet user since the early days and I practically cannot write a blog sample without using Nuget. Fact is NuGet is so flexible that people have even written a deployment tool (Octopus Deploy) using Nuget.

Today we’ll see how we can leverage it from Visual Studio.

A Windows Store App using JavaScript for Accessing Camera

The WinJS library for WinRT applications allow us to build Windows 8 style apps using HTML5 and JavaScript.

In this article, we will build a sample application, and demonstrate the use of Media APIs exposed for accessing Camera device to capture the image.

As Windows 8 will be available on the Tablet, it may happen that the end-user will take snaps with the device and may want to make use of the application to capture a photo and upload it. A business scenario could be that an accident insurance inspector will take snaps of the incident using his device and will upload the images immediately to the insurance office for further processing. This scenario requires an application which will take the snap and upload it.

In the steps shown below, I have explained the use of JavaScript to call Media API..

Step 1: Open VS 2012 and create a new Windows Store application, name it as ‘Store_JS_Camera’:

I1_New_Project

Visual Studio 11 Developer Preview Download Links

In the BUILD Developer conference a couple of days ago, Microsoft introduced the next version of Windows called Windows 8 and next version of Visual Studio called Visual Studio 11. Microsoft released the Visual Studio 11 Developer Preview and Windows Server 8 Developer Preview which will enable devs to start building apps for Windows 8. .NET 4.5 Preview and ASP.NET MVC 4 Preview were also announced.

Here are the download links of these software incase you missed them:

Microsoft Visual Studio 11 Developer Preview (Web Installer) - Visual Studio 11 Developer Preview is an integrated development environment that seamlessly spans the entire life cycle of software creation, including architecture, user interface design, code creation, code insight and analysis, code deployment, testing, and validation.

Microsoft Visual Studio Team Foundation Server 11 Developer Preview - Web Installer - Microsoft Visual Studio Team Foundation Server 11 Developer Preview is the collaboration platform at the core of the Microsoft Application Lifecycle Management suite of tools, which helps teams be more agile, collaborate more effectively, and deliver better software faster.

Visual Studio Team Explorer Everywhere 11 Developer Preview - Developer Preview of the Eclipse plug-in and cross-platform command-line client for Visual Studio Team Foundation Server 11

Microsoft Visual Studio Agents 11 Developer Preview (ISO) - Visual Studio Agents 11 Developer Preview is the essential suite of agents and controllers that enable you to build and test applications across the desktop, server, and cloud. Test controllers and test agents provide the ability to scale out load generation, and support distributed data collection and distributed test execution.

Microsoft Visual Studio 11 Developer Preview Remote Debugger - The Visual Studio 11 Developer Preview Remote Debugger enables you to debug applications on computers that do not have Visual Studio installed.

Microsoft .NET Framework 4.5 Developer Preview - Web Installer - The Microsoft .NET Framework 4.5 Developer Preview is a prerelease version of the .NET Framework. This software installs the components required to develop and run applications that target the .NET Framework 4.5 Developer Preview.

ASP.NET MVC 4 Developer Preview - ASP.NET MVC 4 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework.

Visual Studio 11 Application Lifecycle Management Virtual Machine and Hands-on-Labs / Demo Scripts - Hyper-V virtual machine which works with Windows Server 2008 x64 with hands-on-lab scripts to exercise some of the new Visual Studio 11 application lifecycle management capabilities

Visual Studio 2010: Insert Image in Code

Powered by WPF and MEF, the extensibility model in Visual Studio 2010 is richer than its previous versions.  You can easily extend the IDE, code editor, toolbars etc.

One such extension I stumbled upon recently is the Image Insertion extension that lets you insert images directly in line with your code to help you visualize aspects of your code. How cool! I recently used it to insert some UML diagrams within code. Although one may argue about the usefulness of this extension, it won’t harm to know that such an extension exists, in case you need one.

Download the Image Insertion Add-in from here.

Installing the Image Insertion extension

In case you have never installed an extension, here are multiple ways to do so:

1. VS 2010 introduces the Extension Manager (Tools > Extension Manager) that lets you install an extension. This tool lets you search the Visual Studio Gallery for an extension.

2. Alternatively, you can install an extension directly from www.visualstudiogallery.com. Search for an extension and click the download button. If you choose to open, you will presented with a similar dialog box which installs the extension

image

3. You can use XCOPY to install an extension.

Note: Make sure you restart VS 2010 after installing an extension.

Once you have installed the Insert Image extension, just drag and drop an image on the code editor from either the Solution explorer or from Window Explorer. Here's an example of a UML diagram I dragged and dropped on the code editor.

image

To remove this image, place your mouse cursor over the image and a close button should appear. On saving the file, the image gets saved as a resource file.

Parallel Running Task Window in Visual Studio 2010

Visual Studio 2010 has provided lots of facilities for developers writing applications targeting various .NET versions. The .NET 4.0 Framework has introduced task parallel library using which you can write code which makes use of the available cores on the deployment machine.

Now as a developer, if you are working on multiple asynchronous operations, you can make use of  the Task class. I have already explained the mechanism of coding using task parallel library over here.

Now if you want to view the visual schedule of the parallel tasks and see each object in the thread, Visual 2010 has provided us this capability using Debug > Windows > Parallel Task window.

Let’s consider the following console application:

task parallel library example

Step 1: To view the ‘Parallel Task’ window, put a BREAKPOINT on the ‘taskDepartments’ declaration code as shown below:

parallel window breakpoint

Step 2: Run the application and click on Debug > Windows > Parallel Tasks. You will see the Parallel Task Window as circled below:

parallel task window

Step 3: Now step through the code, and you will find the Task entries in the Parallel Tasks Window as shown below:

parallel task window

The above image of the Parallel Tasks window shows that two Tasks are running. Currently the control is on the ‘taskDepartments’ task object, so the Location provides the operation being handled by the current running task.

parallel task window

Similarly, in the above image, we can see that the task ‘taskEmployees’ is running and handling ‘ReadAllEmployees’ operation.

In both the images, the ‘Thread Assigned’ represents the thread on which the Tasks are running.

Conclusion: With the use of Visual Studio 2010 and Task Parallel Framework in .NET 4.0, it is easy for the developer to work on parallel programming and monitor it.

Visual Studio LightSwitch 2011 RTM Trial

Microsoft recently released the Visual Studio LightSwitch 2011 RTM. This tool is available for free to MSDN subscribers. However those who are not MSDN subscribers can download the RTM trial for 30 days. This can be extended up to 90 days after customers have registered the software.

What is Visual Studio LightSwitch 2011?

As quoted here, Visual Studio LightSwitch is the newest edition of the Visual Studio family and is the simplest way to build business applications for the desktop, web and the cloud. Using application templates, Visual Studio LightSwitch 2011 saves the time and effort of building from scratch, without sacrificing the flexibility needed to create custom applications.  For the end-user developer this means you can quickly create professional quality business applications with minimal code. For the professional developer you can customize LightSwitch with your own code, controls and even build extensions that can add more capabilities than what you get out of the box.

Visual Studio 2010 Professional, Premium, Test Professional or Ultimate users must install Visual
Studio 2010 SP1 before installing Visual Studio LightSwitch 2011.


"Partially Succeeded" TFS status in Visual Studio while upgrading to TFS 2010

While upgrading from TFS to TFS 2010 and to TFS Team Build 2010, you may have come across the ‘partially succeeded’ message. The message also appears when you build a Microsoft Visual Studio 2008 project by using the default upgrade template in TFS 2010.

Microsoft has released a Cumulative update for Team Foundation Server 2010 Service Pack 1 which fixes this and many more issues as listed below:
  • "Partially Succeeded" status in Visual Studio 2008 if you upgrade to TFS 2010 and to TFS Team Build 2010
  • While adding files, Source Control Explorer responds sluggishly in Visual Studio after you install Team Foundation Server 2010 SP1
  • Connection issues to SSAS database from TFS 2010.
On a side note, Microsoft has also released a Team Foundation Installation Guide 2010 that includes instruction for installing Team Foundation Server, Team Foundation Server Proxy and Team Foundation Build Services.

Visual Studio 2010 Update for HTML 5 and CSS3

Microsoft recently released the first Web Standards Update for Visual Studio 2010 SP1 and for Visual Web Developer Express 2010 SP1. This release brings up-to-date support for HTML 5 , and CSS 3 as per the latest W3C specifications. Support has also been added for API’s for JavaScript Intellisense.

This is a welcome update especially for ASP.NET developers and you should download and start using it immediately! This update is FREE.


To read more about this update, follow these links:

Coded UI Tests (CUIT) In Visual Studio 2010

Coded UI Tests (CUIT) is a brand new feature added in Visual Studio 2010 Ultimate or Premium version which allows you to test a a User Interface using automated tests. CUIT allows functional testing for UI and the code gets created with the help of high level languages like C# or VB.NET.

DotNetCurry.com author Gouri Sohoni has written some good articles about CUIT. Here are the links to them if you are interested to learn more about this new feature

Coded UI Test (CUIT) using Visual Studio 2010 - In this article, we will see how Coded UI Test can be created in Visual Studio 2010 by recording the action using CUIT Builder, how to add assertion and how CUIT can be executed. In the article, we will also see another way of creating CUIT by first executing the test case by using Microsoft Test Manager 2010, recording the actions, convert the actions to Code using Visual Studio 2010 and executing it.
Coded UI Test (CUIT) - Convert Manual Test Case to Code using Visual Studio 2010 - In this article, we will discuss another way of creating Coded UI Test CUIT i.e. by using the recording created with the help of Microsoft Test Manager 2010 in Visual Studio 2010.
Coded UI Test (CUIT) – Variations and Editing with Visual Studio 2010 - In this article we will explore advanced features of CUIT like adding multiple UI maps, re-using code, how the CUIT Editor helps and I will also list the best practices of using CUIT in VS 2010.
Coded UI Test: Convert Normal CUIT to Data Driven CUIT using Visual Studio 2010 - In this article, we will discuss how a normal Coded UI Test can be converted to Data Driven Coded UI Test in Visual Studio 2010. We will also discuss various data sources which can be used to provide data to the test method.

Virtual Machine for Visual Studio 2010 and TFS 2010

Microsoft has released a newer RTM version of its Virtual Machine consisting of Visual Studio 2010 and Team Foundation Server (TFS) 2010. This VM also contains new hands-on-labs, demos, power tools, feature packs and updates, VS 2010 SP1, and Team Foundation Server 2010 Service Pack Lab.

This Virtual Machine is available in the virtualization platform of your choice i.e. for Virtual PC 2007, Windows Virtual PC and Win 2008 Hyper-V




If you want Visual Studio 2010 Lab Management, there is a separate VHD for it.

This virtual machine will stop working on November 1, 2011 and during the same time, a newer version of the VM will be available.

Visual Studio Async CTP (SP1 Refresh)

For those who are new to Visual Studio Async, it extends Visual Studio 2010 and provides streamlined syntax for asynchronous development in C# and Visual Basic.

Microsoft recently released a Async CTP SP1 refresh which now includes Visual Studio 2010 SP1 compatibility, APIs for Windows Phone 7 development, and a new EULA with updates regarding usage in production environments. It is compatible with non-English installations of Visual Studio and with Visual Studio Express.

For ASP.NET MVC 3 devs, you can now program in ASP.NET MVC 3.0 as well as use the Aysnc CTP.

Consume Data from Team Foundation Server on Multiple Devices and Operating systems

Microsoft recently released a tool that allows you to expose an OData service for Team Foundation Server 2010. This sample helps developers work with data from Team Foundation Server on multiple types of devices (such as smartphones and tablets) and operating systems.

OData provides a great solution for this goal, since the existing Team Foundation Server 2010 object model only works for applications developed on the Windows platform. The Team Foundation Server 2010 application tier also exposes a number of web services, but these are not supported interfaces and interaction with these web services directly may have unintended side effects. OData, on the other hand, is accessible from any device and application stack which supports HTTP requests. As such, this OData service interacts with the client object model in the SDK (it does not manipulate any web services directly).
To know more, watch a video on how to expose an OData service from TFS 2010

Visual Studio 2010 Service Pack (SP1) Released

Microsoft has released the first Service Pack of Visual Studio 2010. The service pack is available to MSDN subscribers and will be available for others later during the day over here.

Here are the main highlights of this release:

  • Includes Microsoft Silverlight 4 Tools for Visual Studio 2010
  • New Performance wizard for Silverlight
  • IntelliTrace for 64-bit and SharePoint
  • IIS 7.5 Express support
  • SQL Server CE 4 support (available as separate d/l)
  • Preliminary HTML5 and CSS3 support
  • New Razor Syntax Support (available as separate d/l)
  • Support for Microsoft Web Platform Installer (PI)
  • WCF RIA Services V1 SP1
  • Unit Testing support for the .NET Framework 3.5

and much more. Read What’s New in Visual Studio 2010 SP1. Before installing SP1, make sure you read Tips on installing Visual Studio 2010 SP1

As a Web Developer, to be able to develop applications in VS 2010 using Web standards, I would want to see much better support for HTML5 and CSS3!

Visual Studio: Remove Unused References and Assemblies from your Project

When you create a default project in Visual Studio, there are a couple of references and assemblies that get added by default. Just create any new Window, Web, Console or Silverlight project using Visual Studio and check the using directives (only in C# templates) as well as the assemblies that get added.

Visual Studio Usings

You may not need them all. So after you have finished coding, it’s a good idea to remove unused references as well as assemblies from your project to improve code readability, maintainability as well as gain a slight advantage in the applications load time. If you are using a C# code template (VS 2008 and 2010), you can do the following:

Right-click in your Code behind file > Organize Usings > Remove Unused Usings

Remove Unused Usings

You will find that all unnecessary using directives have been removed. Internally Visual Studio scans through the code and determines the using statements that are necessary for the code to compile. It then removes all other Using statements not needed by the project. After clicking on the ‘Remove Unused Usings’ in the image shown above, here’s what’s left

Remove Unused Usings

Similarly if you are using a VB template, you can use the References Property page to remove unused references from the project. To do so, right click the VB project > Properties or use shortcut Alt+Enter. Select the ‘References’ tab and click on the ‘Unused References’ button.

Unused References

Clicking the button queries the project to determine the references that are not used by the project

Remove Unused References

Click on the Remove button to remove the references not needed.

Note: If you are wondering why is the Remove Unused Assembly feature in a VB template and not in a C# template, read this Bug on MS Connect. Till this gets fixed, NDepend could prove useful,

Compact CSS formatting in Visual Studio

Visual Studio provides default formatting settings for the CSS Editor. You can provide style as well as capitalization formatting to your CSS code. Here’s how to do it

Open Visual Studio > Tools > Options > Text Editor > CSS > Formatting. There are 3 different formatting styles available: Compact Rules, Semi-expanded and Expanded

Here’s what each looks like

As you can see, ‘Expanded’ is the most readable but takes extra space. ‘Semi-expanded’ takes up lesser space than Expanded whereas ‘Compact rules’ takes minimum amount of space, but can be unreadable at times.

Similarly you can choose Capitalization formatting as shown below

I usually go with the Compact rules and Lowercase capitalization!

On a side note, you want also want to looks at 7 Free Tools to Minify your Scripts and CSS

Disable Squiggly or Wavy lines in Visual Studio

The ‘Live Semantic Error feature’ in Visual Studio 2008 SP1 and onwards indicates problems in your code immediately as it detects one, without the need for a compile. Red squiggly or wavy lines appear beneath your code that is incorrect or could cause a problem. For example, there is not method called Closing() in the SerialPort class. So as soon as you type it, a red squiggly line appears indicating it is a syntax error.

Now this could be a time saver in many scenarios, but could also be distracting at times. If you want to temporarily turn it off, here’s how to do so.

Open Visual Studio 2008/2010 > Go to Tools > Options > Text Editor > C# > Advanced > and uncheck the ‘Show live semantic errors’ check box as shown below

Now the squiggles will not appear as you type.

Note: When you compile your code and there are semantic errors detected by the compiler, blue squiggles appear beneath the code that is causing the error.

Read some more Visual Studio Tips