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

There have been a huge number of globalization changes; many of them will affect only a minority of users. For a full list, please refer to http://msdn.microsoft.com/en-us/netframework/dd890508.aspx.

I do want to draw your attention to some of the changes in .NET 4.0:

• Neutral culture properties will return values from the specific culture that is most dominant for that neutral culture.

• Neutral replacement cultures created by .NET 2.0 will not load in .NET 4.0.

• Resource Manager will now refer to the user’s preferred UI language instead of that specified in the CurrentUICultures parent chain.

• Ability to opt in to previous framework versions’ globalization-sorting capabilities.

• zh-HK_stroke, ja-JP_unicod, and ko-KR_unicod alternate sort locales removed.

• Compliance with Unicode standard 5.1 (addition of about 1400 characters).

• Support added for following scripts: Sundanese, Lepcha, Ol Chiki, Vai, Saurashtra,
Kayah Li, Rejang, and Cham.

• Some cultures display names changed to follow naming convention guidelines:
(Chinese, Tibetan (PRC), French (Monaco), Tamazight (Latin, Algeria), and Spanish
(Spain, International Sort).

• Parent chain of Chinese cultures now includes root Chinese culture.

• Arabic locale calendar data updated.

• Culture types WindowsOnlyCultures and FrameworkCultures now obsolete.

• CompareInfo.ToString()() and TextInfo.ToString()() will not return locale IDs because Microsoft wants to reduce this usage.

• Miscellaneous updates to globalization properties such as currency, date and time formats, and number formatting.

• Miscellaneous updates to globalization properties such as currency, date and time formats, and number formatting.



TimeSpan Globalized Formatting and Parsing
TimeSpan now has new overloaded versions of ToString()(), Parse()(), TryParse()(), ParseExact()(), and TryParseExact()() to support cultural sensitive formatting. Previously, TimeSpan’s ToString() method would ignore cultural settings on an Arabic machine.


Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010

Garbage Collection

Garbage Collection Prior to .NET 4.0
As you probably know, the CLR allocates memory for your applications as they require it and assumes an infinite amount of memory is available (you wish). This is a mad assumption, so a process called the garbage collector (GC) is needed in order to clean up unused resources. The GC keeps an eye on available memory resources and will perform a cleanup in three situations:
• When a threshold is exceeded
• When a user specifically calls the garbage collector
• When a low system memory condition occurs

To make this as efficient as possible, the GC divides items to be collected into “generations.” When an item is first created, it is considered a generation 0 item (gen 0), and if it survives subsequent collections (it is still in use), it is promoted to a later generation: generation 1 and later generation 2.

This division allows the garbage collector to be more efficient in the removal and reallocation of memory. For example, generation 0 items mainly consist of instance variables that can be quickly removed (freeing resources earlier) while the older generations contain objects such as global variables that will probably stick around for the lifetime of your application. On the whole, the GC works very well and saves you writing lots of tedious cleanup code to release memory.

The GC operates in a number of modes: workstation, concurrent workstation (default for multicore machines), and server. These modes are optimized for different scenarios. For example, workstation is the default mode and is optimized for ensuring that your applications have a quick response time (important for UI-based applications) while server mode is optimized for throughput of work (generally more important for server type applications). Server mode does pause all other managed threads during a garbage collection, however. If server mode were used for a Windows Forms application, this collection could manifest itself as intermittent pauses, which would be very annoying.



Garbage Collection in .NET 4.0
So what’s changed then? Prior to .NET 4.0, a concurrent workstation GC could do most but not all of a generation 0 and 1 collection at the same time as a generation 2 collection. The GC was also unable to start another collection when it was in the middle of a collection which meant that only memory in the current segment could be reallocated.

In .NET 4.0, however, concurrent workstation GC collection is replaced by background garbage collection. The simple explanation (and GC gets very complex) is that background garbage collection allows another GC (gen 0 and 1) to start at the same time as an existing full GC (gen 0, 1, and 2) is running, reducing the time full garbage collections take. This means that resources are freed earlier and that a new memory segment could be created for allocation if the current segment is full up.

Background collection is not something you have to worry about􀀁it just happens and will make your applications perform more quickly and be more efficient, so it’s yet another good reason to upgrade your existing applications to .NET 4.0.

Background collection is not available in server mode GC, although the CLR team has stated they are aiming to achieve this in the next version of the framework. The GC team has also done work to ensure that garbage collection works effectively on up to 128 core machines and improved the GC’s efficiency, reducing the time needed to suspend managed threads

For more information and a detailed interview with the GC team, please refer to http://blogs.msdn.com/ukadc/archive/2009/10/13/background-and-foreground-gc-in-net-4.aspx and http://channel9.msdn.com/shows/Going+Deep/Maoni-Stephens-and-Andrew-Pardoe-CLR-4-Inside-Background-GC/.



GC.RegisterForFullGCNotification()
It is worth noting that from .NET 3.5SP1, the CLR has a method called GC.RegisterForFullGCNotification() that lets you know when a generation 2 or large heap object collection occurs in your applications. You might want to use this information to route users to a different server until the collection is complete.


Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010

Dotfuscator Changes

Dotfuscator is a post-build .NET hardening and instrumentation platform for protecting, measuring and managing .NET applications. Traditionally a reduced functionality version of Dotfuscator has been bundled with previous releases of Visual Studio and VS2010 is no exception. However, the new version of Dotfuscator Software Services CE contains Runtime Intelligence functionality and some great added features including:

• Tamper defense (detect modification of application)

• Application expiration (such as expire an application after 30 day trial period)

• Session and feature usage tracking (allows you to track what the user was actually doing within your application)

• Ability to send tamper and tracking usage to an end point of your choice for later analysis

To access Dotfuscator functionality within Visual Studio on the main menu, go to Tools and select Dotfuscator Software Services. For more information on Dotfuscator please refer to http://www.preemptive.com/dotfuscator.html and for more information on Runtime Intelligence see: http://en.wikipedia.org/wiki/Runtime_Intelligence.


Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010

MEF (Managed Extensibility Framework)

MEF is a new framework for creating customizable applications that can be used by any .NETcompatiblevlanguage. Glenn Block (PM for the new Managed Extensibility Framework in .NET 4.0) says:vQuite simply, MEF makes building extensible apps, libraries and frameworks easy. It shares some common characteristics of other frameworks out there, but it also addresses a whole new set of problems that arise in building extremely large scalable extensible systems. http://blogs.msdn.com/gblock/archive/2008/09/26/what-is-the-managed-extensibilityframework.aspx

Let’s say you have created a Tetris application and want to allow users to extend it by creating their own shapes of bricks. MEF enables you to do this by defining a brick interface and then dynamically loading and resolving the created extensions.

When creating a MEF application, take the following steps:
1. Define areas of the application that can be extended and decorate them with the [Import] attribute.

2. Determine a contract/interface that defines what your extensions must do/be (this could be a simple as they must of String).

3. Create an extension that meets these requirements and decorate it with the [Export] attribute.

4. Modify your application to load these extensions.



Why Use MEF?
Using MEF has the following advantages:
• Microsoft hopes that MEF will become the preferred standard method of creating extensions. By utilizing a standard plug-in model, your extensions could be used in many applications

• MEF provides a number of flexible ways to load your extensions.

• Extensions can contain metadata to provide further information about their capabilities. For example, you may only want to load extensions that can communicate securely.

• MEF is open source and works on VS2008 (www.codeplex.com/MEF).



MEF Catalogs
MEF uses a concept called catalogs to contain extensions. Catalogs come in three different flavors:
• Assembly (extensions are contained in a .net assembly)
• Directory (extensions are in a physical directory)
• Aggregate (a catalog type that contains both assembly and directory extensions)



Metadata
An important feature of MEF is that you can provide additional information about an extension's capabilities with metadata. MEF can then utilize this information to determine the most appropriate extension to load and query its capabilities. For example in the previous logging example you might specify whether the logging method is secure or not and then in high security environments only load extensions that communicated securely. Meta data can be defined at a class or method level.

Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010

VS2010 allows you to create much more advanced customizations than changing the start page or creating snippets. VS2010 has been written from the ground up for extensibility and customization.
• Screens have been rewritten in WPF and managed code.
• The IDE API has been refactored for easier use.
• The IDE API is fully documented.
• New immutable text snapshots make it easier to obtain accurate snapshot of text editor.

Many areas of the IDE can be overridden by creating a MEF component.

So, what can you customize? VS2010 allows you to customize the following areas, among other things:
• Margins and scrollbars
• Tags
• Adornments (items painted on the editor surface)
• Mouse processors
• Drop handlers
• Options
• Intellisense and debugger

Before you can perform any of these customizations, however, you will first need to download and install the Visual Studio SDK. Extensions in VS2010 make heavy use of a new technology called MEF. Before we create any customizations we need to understand a bit about MEF.

A T4 template is a code-generation language that has been around since VS2005. You should be aware of them, as they are used in areas such as Entity Framework and MVC and can be useful for your own development. To see T4 templates in action, create a file with the extension .tt, add some text content, save the file, and note how Visual Studio will generate a code file from the template. You can apply complex logic using T4 templating language to change the output that is generated depending on various conditions. T4 templates in VS2010 are compiled when they are saved (preprocessed).

This means that they are another type that can be instantiated. Scott Hanselman has some great and information on this area so please refer to the following article:

www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx.

T4 templates don’t have Intellisense so your best bet is to download the Tangible T4 plugin:

http://visualstudiogallery.msdn.microsoft.com/en-us/60297607-5fd4-4da4-97e1-3715e90c1a23.

For more see:
http://code.msdn.microsoft.com/DslTools/Wiki/View.aspx?title=What%27s%20new

http://karlshifflett.wordpress.com/2009/10/30/t4-preprocessed-text-templates-in-visualstudio-2010/


Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010

Improved Multitargeting Support
When a new version of Visual Studio/.NET framework is released, it can take time to upgrade and test existing applications. This can prevent you from taking advantage of features such as IDE enhancements if you are not ready to upgrade your application yet. VS2010 contains improved support for targeting previous versions of the framework.

As per previous studio releases, the new project dialogue contains a drop-down menu that allows you to select the version of the framework that you are targeting when creating an application. When you make a selection, Visual Studio will filter the project types you can create to those available in that version of the framework. Note that you can also select the framework version you are targeting in the project properties.

In VS2010 the Toolbox and Properties windows are filtered to display functionality available in the targeted framework version. Previously, some properties that were not available in the targeted framework would still be exposed. VS2010 will even try to display the correct version of third-party components for the targeting framework version.

VS2010 emulates what is available in previous framework versions through reference assemblies. These assemblies contain metadata that describes functionality available in previous versions. VS2010 itself uses the .NET 4 framework, so when adding multitargeting support the team decided against running a previous framework version inside the same process. When your application is compiled to 100 percent guarantee application compatibility, previous compiler versions are used.



Intellisense
Intellisense will now perform partial string matching. For example, if you were to type the word build, note how Visual Studio displays both StringBuilder and UrlBuilder options. This can be very useful if you cannot remember the exact property or type name.
Intellisense also supports lookups based on capitalization. Because all .NET types are pascal-cased, you can simply enter just the uppercase letters of the type. For example, SB would return the type StringBuilder, among others with the same pascal-casing. Intellisense performance has also been improved particularly for JavaScript libraries.



Add References
The add references functionality was previously slower than Mr. Slow in a slow town on a slow day while walking backward. Add reference in VS2010, however, is pretty quick. When the Add Reference dialogue first displays, the focus is set to the Projects tab while separate threads load up the .NET and COM tabs.



Web Development (Code-Optimized Profile)
VS2010 contains some environment profiles such as the Web Development (code-optimized profile). This profile is optimized for code and hides design features. Code-optimized profile can be selected when you first load Visual Studio or by selecting Tools -> Import and Export Settings.



Zoom
As much of the IDE is written in WPF, it was easy for Microsoft to add functionality such as the ability to zoom into the code editor. To zoom into the code editor window, simply press Ctrl and use the mouse wheel to increase and decrease zoom level. You could utilize this feature in presentations/code reviews or to zoom out to help you navigate a lengthy piece of code.



Highlight References
Highlight References allows you to quickly navigate through different instances of the same method call within a file. For example, if you want to navigate through all calls to the ToString method, then click once anywhere on the ToString method text (note you don’t have to highlight the text) and you will find the IDE marks all the other ToString calls in the same file with a light grey background. You can then navigate to the next ToString method by pressing Ctrl + Shift + Down or Ctrl + Shift + Up to return to the previous instance.



Navigate To
Sometimes if you need to find a specific piece of code it can be much quicker to use the search functionality rather than trawl through Solution Explorer. VS2010 improves on the existing “search” and “search in files” functionality with the Navigate To window. To bring up the Navigate To window, simply press Ctrl and comma or select Navigate To on the Edit menu. You can then enter a phrase you want to search for in your solution, and Navigate To will immediately filter results as you type. You can then click on these results to be taken directly to the results location. Navigate To will perform partial and in-string matches, and also supports pascal-casing searches (for example, BT would return a class called BigTiger). Navigate To supports all commonly used types of file such as C#, VB, and XML, and is much quicker and easier to navigate than previous search methods.



Box Selection
Box Selection is one of my favorite new features. It allows you to quickly perform the same change on many lines of code. To use box selection, place the cursor where you want to make the change, and then hold down Shift + Alt in combination with the arrow keys to create a “box” where the change will be applied. Finally, enter your change and it will be applied to all the selected lines. Box Selection could, for example, be used to refactor a number of class variables’ access level from private to public in one edit.



Call Hierarchy
The Call Hierarchy window allows you to see all calls made to a particular method and all calls from the method. Call hierarchy is recursive. To open the Call Hierarchy window, right-click on a method, property, or constructor, and select View Call Hierarchy. The Call Hierarchy window will then open, displaying calls to and from the method. Note that you can filter the Call Hierarchy window by solution, project, and document.



Code Generation
A great feature in VS2008 is that you can enter a new method name that doesn’t exist and have the IDE create a stub of it for you (to do this enter a method name that doesn’t exist, press Ctrl + . and select the Generate method stub option). VS2010 expands on this functionality and allows you to create classes, structs, interfaces, and enums in a similar manner. This is a great feature when you are starting the development of an application and particularly suitable for a TDD style of development. Let’s try this out now.

1. Create a new console application

2. Enter the following code:
Zebra MyZebra = new Zebra();

3. Either click the smart tag (fiddly) beneath the Z in zebra or press Ctrl + . (much better) to bring up the menu.

4. You now you have the choice of creating a Zebra class in a separate file (Zebra.cs) by selecting “Generate class” or you can select “Generate new type” to bring up an options screen that allows greater control of generated type. In this example please select “Generate new type.”

5. The Generate New Type screen will appear, allowing you to specify a number of options such as access level, file name, item to create, and so on. Select Class on the Kind drop-down menu and change the access level to Internal.



Consume First Mode
Intellisense is a great feature, but can sometimes get in your way. For example, imagine an application where you have a class called TigerCage and you now want to create a Tiger class. If you want to use VS2010’s new class generation features and start typing Tiger then Visual Studio’s Intellisense will jump in and smugly change your code to TigerCage. To resolve this issue Intellisense now operates in two modes: default and consume first mode. Consume-first mode prevents Intellisense from automatically completing a type or member that has not yet been defined. To switch to consume first mode press Ctrl+Alt+Space. You can enter Ctrl + Alt + Space again to switch back to the default mode.



Breakpoints
VS2010 allows you to export/import and label breakpoints. You can use this feature to share a collection of breakpoints with a colleague or quickly return to a previous debugging setup. Note that the exported file holds the breakpoint location by line number, so if you should modify your code and import breakpoints they will no longer be positioned correctly.

Individual breakpoints can be exported by right-clicking on them and then selecting the Export option. Or you can export all breakpoints (or those matching a specific search criteria) by opening the Breakpoints window (Debug->Windows->Breakpoints) and selecting the “Export all breakpoints” option. Breakpoints can be imported in the Breakpoints window.

VS2010 allows you to apply a label to a breakpoint. This may be useful to associate it with a particular issue or with grouping in the Breakpoints window. To label a breakpoint, right-click on one and select the Edit labels option. VS2010 will then give you the option of entering a new label for the breakpoint or reusing an existing one.



Toolbox
If you start typing a letter, the toolbox will jump to items containing the letter typed. You can also tab through to the next item that matches.



Code Snippets
Previous versions of Visual Studio contained a feature called snippets that allowed you to save blocks of code for later insertion, saving you on the retyping (or remembering) them. VS2010 contains a number of new snippets (in particular for ASP.NET) and allows you to easily create your own. Although you can create your own snippets in VS2008, it wasn’t an easy process without the use of third-party applications (e.g. Snippet Editor http://msmvps.com/blogs/bill/archive/2007/11/06/snippet-editor-2008-release.aspx).
This changes, however, in VS2010 and is now very easy.

• Expansion (the snippet is inserted at the cursor)

• SurroundsWith (wraps around existing code)

Let’s take a look at this now and create a code file header snippet:

1. Add a new XML file to your project called verHeader.snippet (snippets always have the extension .snippet).

2. Right-click on the editor window and select Insert Snippet->Snippet. VS2010 will then create a basic XML snippet template.



Loading the Snippet into Visual Studio
Before we can use our snippet, we need to load it into Visual Studio. Because snippets are pretty useful, you will probably want to create more than one. Follow these steps to create a new directory somewhere on your computer called MySnippets.

1. Copy the verHeader.snippet file in your solution to the snippets directory you just created.

2. On the main menu, go to Tools, then Code Snippets Manager and you should see a screen.

3. Select Import

4. Select the snippet you saved earlier

5. Click OK

6. Visual Studio will then confirm you want to place the snippet in My Code Snippets directory That’s it your snippet is ready to use. You can now use this snippet by typing “codehead.”



Using Snippets
There are a number of ways to add snippets to your code. No doubt the quickest way is to use the trigger word (such as textbox in an ASP.NET app), but sometimes you may not know the trigger word to use. In that case you can pick the word from the snippet dialogue. To open the snippet dialogue, right-click on the editor, Select Insert Snippet, and you can then choose from either the ASP.NET or HTML snippets. You can also press Ctrl + K and then Ctrl + X to bring up the Insert Snippet enhancement, which allows you to navigate through them using the keyboard.



Creating Custom Start Pages
VS2010 allows you to customize the start page that is displayed when the IDE first loads. You could use this feature to display items such as current bugs, last night’s build status, and so on. On my Windows 7 machine, this directory is held at the following path: C:\Users\alex\Documents\Visual Studio 10\StartPages.

1. Open the project StartPage.csproj and note how StartPage.xaml is a standard XAML page with some Visual Studio-specific controls to display items such as recently opened projects.

2. Perform a simple modification, such as altering some of the text content.

3. Save the file with a new file name, such as CustomStartPage.xaml, in the same directory. Before you can use your new start page, you have to select it in Visual Studio options. Go into Tools->Options then select the Startup node. Select the new custom start page from the Custom Start Page drop-down menu. Close Visual Studio and reopen it. Your new start page should now appear the next time Visual Studio is loaded.

Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010

VS2010 and .NET 4.0 lay the foundations for the next epoch of .NET development and correct a number of omissions. I consider that we can divide the changes under four main headings:
• Efficiency
• Maturation of existing technologies
• Extensibility
• Influence of current trends

Let’s take a whirlwind tour of these now.



Efficiency
One of the first things you will notice in VS2010 is the shiny new WPF-based IDE. The IDE contains some great features available previously only in add-on products such R# and Refactor (note there is already a VS2010 version of R#, yay!) IDE highlights include box selection, snippets, class stub creation, call hierarchy, and quick search.

There are also some great language enhancements that can make code cleaner, such as optional and named parameters, dynamic functionality, and changes to variance. Some of these changes will also assist developers working with COM, who frankly need all the help they can get, poor guys and gals (a moment of respect, please).



Maturation of Existing Technologies
Many .NET-based technologies, such as ASP.NET, have been around for some time now and haven’t changed hugely in this release. Microsoft has, however, fixed a number of long-term omissions in ASP.NET and introduced some useful tweaks.

Toward the end of 2008, Microsoft announced that future versions of Visual Studio would include the popular JavaScript library, jQuery. Although not strictly a .NET change, jQuery is a very useful framework that you will defiantly want to make use of in your web applications. The enhancements to Microsoft’s own Ajax libraries, which make it very easy to bind to data with client script.

Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) are much more closely integrated in this release. WF undergoes a radical overhaul with a much-improved designer, introduction of new activities, and easier customization. WCF becomes simpler to use and also introduces new service discovery functionality.

WPF has some great additions, with an improved designer, multi-touch, and Windows 7 task bar support. I will also be taking a quick look at Silverlight 3. Even through Silverlight is not a .NET 4.0 technology, I believe it is an important release. If you have never used Silverlight before, which contains a brief introduction to Silverlight. Entity Framework received much criticism when it was first released, and the team has attempted to address these criticisms in .NET 4.0.



Extensibility
VS2010 is your flexible and extensible friend. You may have already heard that much of the IDE is now written using WPF and can be customized with the Managed Extensibility Framework (MEF).



Influence of Current Trends
Software is not developed in a vacuum, and certain trends have undoubtedly influenced VS2010 and Microsoft’s product line.



Multicore Shift
Due to various physical limitations, CPU manufacturers are now concentrating on releasing multicore processors. Writing programs to run in parallel is difficult, but fear not: VS2010 and .NET 4.0 have fantastic new parallelization constructs and debugging facilities..



Unit Testing and Test-Driven Development
Unit testing and test-driven development are becoming increasingly popular in software development. VS2010 contains a number of IDE enhancements to assist with these strategies. Other related changes that may be of interest are the new dynamic features and the DLR and ASP.NET MVC. OK, ASP.NET MVC isn’t .NET 4.0, but again it is an important interim release.



Cloud Computing
Cloud computing must win the buzzword of the year award for 2009. It is becoming an increasingly popular way to reduce costs and simplify management of infrastructure. Windows Azure is Microsoft’s entry to this area, and I take a look at its capabilities and potential uses. Note that if you purchased Visual Studio with MSDN, you even receive free Azure time.


Source of Information : Apress Introducing dot NET 4.0 with Visual Studio 2010


Subscribe to Developer Techno ?
Enter your email address:

Delivered by FeedBurner