UK 2008 Launch resources

Thu, March 20, 2008, 07:13 PM under Events | Orcas
On Wednesday we had the 1-day free multi-track event in the UK to celebrate the launch of Visual Studio 2008, Windows Server 2008 and SQL Server 2008.

The Windows and SQL tracks basically took the identical slides/demos from the US launch and found local speakers to deliver them. The benefit of that is that the content is not a million miles from the UK Virtual Launch site (which has the US recordings).

For the Visual Studio track I specified session titles and abstracts for 8 complementary developer sessions and "recruited" top speakers to deliver it. If you were there and need to contact the speakers for resources here are links for finding them: Guy Smith-Ferrier, David Gristwood, Andy Wigley, Michael McClary, James O'Neill, Amanda Silver, Mike Taulty, Mike Ormond and mine.

Five VS2008 Smart Client features

Thu, March 20, 2008, 07:10 PM under dotNET | Orcas | VisualStudio
I have created a Smart Client session that I am repeating at various events and it is basically 5 demos. If you attended that session and heard me refer to my blog for more detailed videos of the 5 things, then please find the list below:

1. WPF and WinForms Interop: blog, screencast.
2. Managed AddIn Framework: blog, screencast and code.
3. Client Application Services: blog, screencast and code.
4. ADO.NET Sync Services v1.0: blog, screencast and code.
5. VSTO v3.0: blog and screencasts.

In addition to those links, when people ask me about other Visual Studio 2008 resources I always point them to the Top 10 and they are happy so hope you are too :)

MAF screencasts

Mon, February 25, 2008, 04:27 AM under dotNET | Orcas
One of the hidden gems of .NET Framework v3.5 is the Managed AddIn Framework (MAF) that I've touched on before on these 3 short blog posts: AddIn.dll, Windows.Presentation.dll, VSTO dependency on it.

It is not the easiest of technologies to get your head around without some guidance, so I hope you find useful this introductory quickstart 18-minute screencast (part 1). If you are then hungry for more and in particular on how the MAF delivers on version resiliency, then watch my second 18-minute screencast (part 2). You can get all 3 states by downloading this ZIP file of all Visual Studio projects.

.NET Client Application Services

Sat, February 23, 2008, 02:11 PM under dotNET | Orcas
Back in May 2007 I posted (Client Application Services) some links that completely describe this new VS2008 and Fx 3.5 feature. If you missed it back then, then please revisit the post to read about it.

If you prefer watching an 18' video that fully gets you started, I have exactly that for you on channel9: Client Application Services with VS2008. The final code that I created is in these two projects.

ADO.NET Sync Services

Thu, February 21, 2008, 02:15 PM under dotNET | Orcas
With the release of Visual Studio 2008 we also get v1.0 of ADO.NET Synchronization Services that allows you to build Occasionally Connected Applications by allowing synchronization of remote data with a local cache of the data. Sync Services is the first part of the larger framework still in development: Microsoft Sync Framework (MSF). MSF was part of the announcements at Tech Ed Europe 2007. The first CTP of the Sync Framework is available and it includes a pre-release of v2.0 of Sync Services for ADO.NET. Stay tuned on the Sync Framework blog (which includes links to other relevant blogs down the side). I also believe there will be an update near the SQL Server 2008 release, but I am not sure. There is a very useful FAQ on Sync Services on Steve's blog.

To be clear, here I am still talking about v1 of Sync Services, which ships with VS2008 RTM. If you do not have VS2008, you can still get Sync Services by downloading SQL Compact Edition v3.5 (which is what holds the local cache). Included in the download are the 3 assemblies that complete the picture. So you may be thinking: "if I can get it as a standalone download, why use VS2008 and not stick with VS2005?". The answer is that there is a very smart Configure Data Synchronization dialog wizard as part of VS2008 that generates tons of code and also performs other actions that IMO are too tedious for easily using VS2005 with Sync Services. To invoke the wizard in a new VS2008 project (v2.0 or v3.0 or v3.5) right click on the project node and add new item and choose the "Local Data Cache" item template – then just follow your nose (or the documentation and numerous links above ;-))

If you want a quick intro then put 15 minutes aside to watch my screencast introducing the ADO.NET Sync Services. The Visual Studio project that I create in the video can be downloaded here.

WMI Provider Extensions in .NET Framework v3.5

Mon, February 11, 2008, 07:05 AM under dotNET | Orcas
A long time ago I created a hyperlinked list of the new assemblies in .NET Framework v3.5 and the only one that did not have a hyperlink was the WMI assembly (item 6 on the list).

So, I was very pleased that in last week's MSDN Flash we published a 500 word succinct article on that very topic. For the non-Flash subscribers, scroll down on this page to read it.

Video on debugging into the .NET source code

Wed, January 16, 2008, 03:32 PM under Orcas | VisualStudio
Finally, what was promised back in October is now available to everyone with Visual Studio 2008 installed: debug into the actual .NET Framework source code!

All you need is VS2008 and 15' to watch my screencast that shows you step-by-step how to enable this feature.

While watching my video start downloading the hotfix for VS2008 which will make the whole experience a lot faster than what it is without it. Note: I recorded the video without the QFE.

For questions and/or more info, visit the blog of the man that made this feature possible.

DataSet enhancements in VS2008

Tue, December 11, 2007, 03:12 PM under dotNET | Orcas
For those of you using the DataSet, you'll be happy to know that there are enhancements to it, including these three:

1. Hierarchical Updates: Read.
2. Separate DataSets and TableAdapters for multi-tier solutions: Read, watch.
3. LINQ to DataSet: Read and Watch.

Bonus: Read a nice collection of How To and walkthrough articles for the dataset designer.

LINQ to DataSet video

Mon, December 10, 2007, 09:07 AM under dotNET | Orcas | LINQ
I have already written about LINQ to DataSet, and for more details than what I provided you should follow the links I suggested on that post. In addition, I just published an 18' video on LINQ to DataSet which I hope you enjoy...

Code snippet for property old style

Tue, December 4, 2007, 03:18 AM under Orcas | VisualStudio
When I first realised that the prop snippet now generates automatic properties in C# I thought it was cool. The more I write code in VS2008 though I find that when I need to write a property with get/setters that are explicitly implemented, it becomes tedious – I used to rely on prop in VS2005 too much I guess. This is easily rectified by adding a new code snippet of course.

Creating snippet is so easy it should be illegal :), but to save you the manual work here is the one I created for this purpose (propOld). Simply "save as" to your local drive and then from Visual Studio 2008 menu "Tools->Code Snippet Manager" click the "Import" button; then in a C# file type proOLD and hit TAB (instead of prop+TAB).

Compiler Features in C#3 and VB9

Tue, November 27, 2007, 01:51 AM under Orcas | VisualStudio
Visual Studio 2008 uses C# 3.0 and VB9. It uses the same version of the compiler regardless of which version of the framework you are targeting. I've talked about every new language feature and how they can be used cross-framework before, so I won't repeat myself – jump to item 4 of this post.

All I am going to do in this post is offer the slide we use at UK events that demonstrates pictorially the overlap of features between the two languages and where each one differs in terms of new features. This slide was started by my colleague MikeT (who has a great selection of UK VS2008 resources); I evolved the slide to look like this:

VS2008 Beta 2 to RTM menu changes and readme

Mon, November 26, 2007, 02:07 AM under Orcas | VisualStudio
I started the Beta 2 to RTM changes on this post and then posted some breaking changes about this, that and the other and also posted some minor amendments here and there. To close it all off, below are the remainder differences that I observed:

1. If you access the Samples via the Help menu, you'll notice there is now a Readme displayed (apparently some people fell over at the first hurdle that the readme addresses).
2. Previously in web projects, you would access the "Manage Styles" and "Apply Styles" windows from the Format menu. Now the two menu items have moved to the View menu under their brother who was always there: "CSS Properties".
3. The Database Publishing Wizard is now built in to Visual Studio, no need for separate download:


For more, please do read the Visual Studio 2008 readme which includes the steps required to go from Beta 2 to RTM.

Go To Type Definition in VS 2008

Sat, November 24, 2007, 11:21 AM under Orcas | VisualStudio
I was reading this post on the VB blog about hidden gems in VB with the VS2008 release. I knew all of them until I came to item 8: the "Go To Type Definition" menu (I am not sure if this was functional in Beta 2...). This is available only on the variable declaration and it takes you to the definition of the type of the variable.

But hang on! Couldn't we always do that? Yes, we could: The existing "Go To Definition" menu does that if you execute it by right clicking on the type rather than the variable. So, the only benefit of the new "Go To Type Definition" menu is for scenarios where you are using local variable type inference and hence don't have the type explicitly appear in your code (in order to use the existing "Go To Definition" menu).

I thought that was cute, but something was bugging me about introducing a whole new menu item for this purpose. Couldn't the VB team simply go to the type definition if I selected "Go To Definition" on the Dim keyword? I checked with some C# code that uses local variable type inference, and indeed that is what it does when you select "Go To Definition" on a var. As it happens, I prefer C#'s approach on this one.

Regardless of what I prefer, I would have like some consistency here between the two language approaches but I am sure this is where the product teams tell me that they are catering for two different audiences and I don't want to open that can of worms again.

I'll finish off by saying that I prefer what VB means by go to definition for a type, as opposed to how C# does it. In VB, going to a type definition that is not in your code, is interpreted as going to the Object Browser. In C# (since VS2005), it disassembles the signatures of the type from the external binary and presents it in C# code in a separate file – yuck! Why can't C# just take me to the OB where I can see in a more concise format all signatures and documentation? There should be a separate command for disassembling the type in header style just in case I need to copy/paste something... Anyway... mini-rant over.

VS2008 works with SourceSafe 2005

Fri, November 23, 2007, 03:28 AM under Orcas | VisualStudio
...but you need an update. Please read this post for context and where to get the update.

Thanks to one of my readers (Martin Normak) for pointing this out to me.

VB WPF project with option Strict On in VS 2008 RTM

Thu, November 22, 2007, 02:56 AM under Orcas | VisualStudio
In my global Visual Studio project settings for VB projects I always have Option Strict set to On, so any new VB project I create has this setting without me having to do it manually every time.

If you do the same as me above, then when you create a Visual Basic WPF project in Visual Studio 2008 RTM, you may get a compilation error before you have a chance to write any code:

Option Strict On disallows implicit conversions from 'System.Windows.Application' to 'WpfApplication1.Application'.

Double click on the compilation error in your Error List window and it will open the offending file: MyWpfExtension.vb and specifically the ReadOnly Application property that returns an object of type Application. The problem is that the single return statement does not perform a cast:
Return Global.System.Windows.Application.Current
So you have to change it (or in fact choose the cool auto correction option to change it for you) to:
Return CType(Global.System.Windows.Application.Current, Application)

WARNING: The following step has the potential to irrevocably cripple your machine so take backups if you decide to proceed!

If you want to change this globally on your machine and are willing to take your life into your own hands and venture into unsupported territory then you can edit the following two files (you’ll need to unzip, edit the file, and re-zip):

%programfiles%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache\VisualBasic\Windows\1033\WPFApplication.zip\MyWpfExtension.vb

%programfiles%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\VisualBasic\Windows\1033\WPFApplication.zip

Did I mention that the former action is not a supported scenario by Microsoft or endorsed by the product teams? Yes, good.

NewProject and AddNewItem dialogs in VS 2008 RTM

Wed, November 21, 2007, 04:54 AM under Orcas | VisualStudio
If you were running Visual Studio 2008 Beta 2 and have just moved to RTM, you'll find these minor changes in the New Project dialog:

1. When clicking on the top level Office node it shows you all the Office templates (2003 and 2007) as per the screenshot; before it would not show you anything.
2. There is a new Reporting node that has the "Reports Application" template that previously was under Windows.
3. The SharePoint Worklfow project templates now also appear under the Workflow node (in addition to appearing under the Office->2007 node).

You'll also find some minor changes in the Add New Item dialog:

4. All the WPF item template icons have had a face lift (as per screenshot above).
5. In client projects there is a new Reporting node (equivalent to item 2 above) that contains two templates: "Report" and "Report Wizard".
6. In a web project there is a new item template for Nested Master Page.

HTML, CSS, Script errors as warnings in VS2008 RTM

Tue, November 20, 2007, 05:03 PM under Orcas | VisualStudio
Comparing VS RTM to Beta 2, here is a good one:
Tools -> Options -> Text Editor -> HTML -> Validation

...enjoy the two new checkbox Options to treat errors as warnings :-)

An item placeholder must be specified on VS 2008 RTM

Tue, November 20, 2007, 07:45 AM under Orcas | VisualStudio
If you open your existing Beta 2 web projects with VS 2008 RTM, and you were using the new ListView (one of the 3 new web controls), you may face the following error:

System.InvalidOperationException: An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server".

There are two changes to be aware of:
1. Instead of itemContainer (which is probably what you are using from Beta 2), you must now change the id to be equal to itemPlaceholder. Make this change and your project will compile.
2. The control that has the id="itemPlaceholder" does not get rendered at runtime anymore (it gets removed and replaced with multiple instances of the ItemTemplate). So if you were using for example a ul and had some CSS on it for the li, this styling is now lost. The solution, of course, is to place the outer element (e.g. ul) on its own and within it place a asp:Placeholder whose ID you set to "itemPlaceholder".

An example of both of the above:
<LayoutTemplate>
<ul class="myCSSrule">
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
Easy once you know how ;-)

Could not load file or assembly in VS2008 RTM

Tue, November 20, 2007, 02:34 AM under Orcas | VisualStudio
If you open your existing Beta 2 web projects with VS2008 RTM you may face the following error:

Could not load file or assembly 'System.Data.DataSetExtensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

The reason for this is that many of the pre-release Fx 3.5 assemblies did not have their version set to 3.5 yet (I covered that in this post), but now they do. So if you change the version from "2.0" to "3.5" in the web.config file your project will build fine again.

At the bottom of that same post I also mentioned the weirdness of System.DirectoryServices.AccountManagement and you'll be pleased to hear that it is now placed in the correct folder and does appear in the references dialog as well.

VS2008 RTM for non-MSDN subscribers

Mon, November 19, 2007, 11:01 AM under Orcas | VisualStudio
Judging by the amount of emails I received, not everyone is an MSDN subscriber and my smiley face didn't put you off from telling me that! So, for the non-MSDN subscribers, if you cannot wait for the general availability date early next year, download a trial now and upgrade later.

Visual Studio 2008 build version 9.0.21022.08

Mon, November 19, 2007, 03:11 AM under Orcas | VisualStudio
All MSDN subscribers can now down load the final RTM version of Visual Studio 2008. If you are not an MSDN subscriber, I guess this is a great incentive to join right now :-p

If you are looking for what is great in VS2008 compared to VS2005 go read my Top 10 hyperlinked list.

If you have been driving VS 2008 Beta 2 for a while and are wondering what is new in RTM then the answer is primarily bug fixes and performance boosts. Two (out of many) quick examples: I noticed many bug fixes for WPF projects and performance improvements not just in the WPF designer but also in script intellisense. There are also some minor enhancements and some aesthetic and usability improvements for example some windows render better on low resolutions such as the Client Application Services dialog. Another is that the UAC Settings option which was previously erroneously available for Office projects (instead of just executables) is now correctly disabled. Finally, we now get an Upgrade button on the About dialog:


I'll cover more of these Beta2->RTM changes over the next 2 days, so check back.

Top 10 things to know about Visual Studio 2008 and .NET Framework 3.5

Fri, November 2, 2007, 04:54 AM under dotNET | Orcas | VisualStudio
The list below is not in order of importance, instead it is in the order I suggest you explore this new release.

1. VS2008 and Fx 3.5 will officially launch together in February but will be available to developers by the end of November 2007. The same type of Visual Studio SKUs/Editions available with VS2005 will also be available with VS2008 including a brand new one: VS2008 Shell. VS 2008 is a great Vista client, has better aesthetics and a bunch of new usability features including enhancements for multithreaded debugging.

2. Fx 3.5 continues with the additive approach that we introduced with Fx 3.0 while still not introducing a new CLR. As a reminder, Fx 3.0 simply added to Fx 2.0 without changing or removing anything in the existing assemblies (it added WPF, WCF, WF and CardSpace). So, Fx 3.5 simply adds some assemblies to the existing set of DLLs that Fx 2.0/3.0 comprises of. This means that simply installing the framework should not affect your existing solutions. Note however that Fx 3.5 depends on Fx 2.0 SP1 and Fx 3.0 SP1, which will ship at the same time.

3. VS2008 has a new simple yet powerful feature: multitargeting. The ability to create projects targeting different .NET Framework versions (2.0, 3.0 and 3.5). This means that even though VS2008 can be installed side by side with VS2005, you do not need VS2005 any longer since VS2008 offers a superset of the functionality.

4. There are many new C# 3.0 and VB9 language features (inc. automatic properties, relaxed delegates, object initialisers, type inference, anonymous types, extension methods, lambdas and partial methods). The compilers emit backward compatible IL, which is to be expected since there is no new version of the CLR. In plain terms this means that all the new language features can be used with existing v2.0 projects (due to the multitargeting feature mentioned above)! VB developers also get enhanced intellisense amongst other IDE features.

5. The headline feature of this release is LINQ (Language Integrated Query). LINQ depends largely on the language features that were introduced and also on bits of the Fx 3.5 (4 assemblies to be precise). LINQ is a new declarative paradigm for querying data sources in a consistent manner, regardless of what the data source is: in memory objects, XML, SQL, DataSet or anything else (because LINQ has been architected to be fully extensible). The future looks even brighter with efforts such as PLINQ.

6. For the web developer, ASP.NET AJAX ships out of the box with improvements and ASP.NET 3.5 includes 3 new controls. There are also enhancements in the IDE that can be used in ASP.NET 2.0 projects too, such as support for JavaScript intellisense and debugging, a new CSS engine and an HTML designer that supports Nested Master Pages.

7. For the client developer, new features include WPF project templates out of the box, a new WPF designer with integrated support for interop between WinForms and WPF. FireFox support for ClickOnce and XBAP deployments. Now, you can take advantage of ASP.NET provider services and also embed UAC manifests for application running on Windows Vista.

8. For the office developer, there is full support for 2007 Office customisations as well as Office 2003 templates. Support include outlook form regions, ribbon customisation, custom task panes, actions pane, Word content control databinding and interop with VBA.

9. For the server developer, WCF and WF templates now ship out of the box and play better together. WCF now supports a SOAP-less HTTP programming model as well as syndication and JSON serialization. There is a good collection of links for these here.

10. For the mobile developer, there are tons of new features including support for Compact LINQ and Compact WCF and many other NETCF features. At the IDE level we get Unit Testing for devices amongst other goodies from the VSD team.

11. Bonus item: It is only via VS2008 that you will be able to debug your code down into the .NET Framework methods.

XML Schemas dialog in Visual Studio 2008

Tue, October 30, 2007, 03:47 PM under Orcas | VisualStudio
A neat feature of Visual Studio has always been that you can associate a schema with an XML file and then you get intellisense in the XML for elements and attributes. In fact, if you annotate your XSD file, you can even get comments in the intellisense. Read more about the XML editor on MSDN and if you are sticking with VS2005, check out a much older blog post by Aaron.

Well, the Visual Studio 2005 dialog for picking schemas has had a facelift in Visual Studio 2008. I am talking about the dialog that appears when you have an XML document open and then from the Properties window click on the Schemas property. In VS2005 it looks like this:


On the original dialog above, note how the information presented is in a TreeView: Location of the xsd file (tree nodes with folder icon) and File Name (on the tree node with xsd icon) and the Target Namespace (in brackets on the same node). You can also select the xsd file via the tree node checkbox (i.e. a binary decision: Use or Don't Use). The final thing to note is the (mis)title: XSD Schemas ;-)

In VS2008 you can also bring it up from the XML menu:

...its title bar now has more accurate text:

The body of the dialog does not use a TreeView; instead it is a grid with an XSD file per row and 4 columns (from right to left): Location, File Name, Target Namespace and Use (all of them sortable). Take a glimpse at a full screenshot here and notice how you can easily Remove XSDs as well.

Other than a GUI re-layout (which is an interesting study in its own right if you are into that kind of thing), there is additional functionality. The Use column is not a binary decision like before, but rather a combobox with 3 options as the following screenshot shows:

At this point, I'll hand it over to the new MSDN documentation that describes the 3 options. Essentially, now you can remove the automatic binding to a schema based on a namespace, without having to remove the namespace from the XML file itself.

New in CardSpace with Fx 3.5

Tue, October 30, 2007, 02:27 AM under dotNET | Orcas
When I talk about the .NET Framework v3.5 release, I touch on the enhancements coming for NetFx v3.0 technologies i.e. for WPF, WCF and WF. Invariably there will be a question: What about CardSpace? For CardSpace all I know is that there are UI enhancements (play with the latest bits and you'll spot them). Today, I learned (via Mitch) that you'll be able to utilise CardSpace without an SSL certificate. Any other CardSpace questions, please use the aforelinked blog ;-)

VS2008 for web developers

Mon, October 29, 2007, 02:52 AM under Orcas | VisualStudio
The top 3 Visual Studio 2008 IDE features for web developers, in my opinion, are:
1. New split view designer with new CSS support.
2. JavaScript intellisense and debugging enhancements.
3. Nested Master Page support.

Note that due to the multitargeting feature, the tool/IDE enhancements are also applicable to developers targeting ASP.NET 2.0 ;)

If you are looking at what is new from a platform perspective, then the top 3 IMO are:
A. ASP.NET AJAX support out of the box - 'nough said.
B. Three new ASP.NET 3.5 controls.
C. ASP.NET MVC Framework. Technically not part of ASP.NET 3.5, but it will be released later as an addition and it is too cool not to mention ;-)

BTW, back in March I listed some other blogs that you should be following for web-specific Visual Studio resources.

Support for Nested Master Pages in VS2008

Fri, October 26, 2007, 08:34 AM under Orcas | VisualStudio
As cool as master pages were when introduced with VS2005/ ASP.NET 2.0, the designer was not capable of rendering nested master pages and I imagine that for some that hindered their ability to make the most of this cool feature. In VS2008, the new HTML designer that is shared with Expression Web supports nested master pages. Read all about this on ScottGu's blog post.

The key is that when you bring up the Add a New Item dialog and select a master page template, it will allow you to check the box that offers the option to base it on an existing master page. See this screenshot.

With earlier drops of Visual Studio, the above only applies when you create a new Web Site. It doesn't apply when you create a new ASP.NET Web Application project, i.e. there is no check box there. See this screenshot.

I strongly suspect that when VS2008 is released, we will have also added a new item template for the latter case... maybe something called Nested Master Page ;-)

Five VSTO v3.0 (in VS2008) videos

Sun, October 21, 2007, 05:30 PM under Orcas | VisualStudio
Having looked at the Office extensibility stuff in Visual Studio 2008 I can honestly say: if you are a windows forms developer and you choose NOT to explore the Office customisation story, then you are genuinely doing yourself a disservice and seriously missing out. I first showed some enthusiasm on this topic through my post: Office development through pictures.

To help you go further, I have recorded 5 short screencasts:
1. Ribbon customisation.
2. Custom Task Panes and Actions Pane.
3. Outlook Form Regions.
4. Word Content Controls.
5. VBA interop with VSTO.

In addition to these videos, there are many online resources to read. There are 6 great dedicated blogs (see links from the bottom of this post) and then there is the online documentation and the Office dev centre. If you have specific questions, please visit the very active free online VSTO Forums.

WPF from WinForms in VS2008

Fri, October 19, 2007, 08:49 AM under Orcas | VisualStudio
Following on from my post about interop between WPF and WinForms, I produced a screencast demonstrating the mechanics. In the process you also get to see the WPF designer in VS2008 if you haven't seen it already. Check out the 17' video here.

WPF and Windows Forms integration

Wed, October 10, 2007, 02:23 PM under Orcas | VisualStudio
Background
Any client developer that has seen a good Windows Presentation Foundation demo/presentation will probably be salivating at the prospect of playing with this cool technology and potentially planning in their heads how they can move their applications from Windows Forms to WPF. The fact is that you don't have to and in fact shouldn't just do that yet, despite what you may have heard from overzealous presenters. Today, WPF is a great choice for consumer applications, ideal for applications where having a WOW factor is part of the requirements and definitely the only choice for software houses that have both designers and developers working on the same projects. For the rest of us building LOB apps, Windows Forms still work great and, even better, can interop with WPF if required for specific use cases. There are many resources for bidirectional interop between WPF and WinForms as well as between WPF and Win32.

The Links
In Visual Studio 2008 we get designer support for these scenarios. If you are in a WPF project simply drag the WindowsFormHost control from the toolbox and point it to a WinForms UserControl. I am more interested in the reverse scenario, so in a Windows Forms project drag the ElementHost and point it to a WPF UserControl and then you can use that WPF control (set properties/call methods, handle events etc) from your winforms. Both of the host classes are implemented in the same namespace, in the WindowsFormsIntegration.dll assembly (part of WPF).

As you can see, other than the two aforementioned classes, there is a PropertyMap class that translates properties from winforms control to WPF elements (with help from the PropertyTranslator delegate) and you can read more about it on MSDN's aptly named Property Mapping page. In the same namespace you can also see 4 subclasses of EventArgs (ChildChanged, IntegrationException, LayoutException and PropertyMappingException) used by events.

"Hello World"
1. In VS2008, create a new WPF User Control Library project.
2. Using the designer for UserControl1.xaml create some UI or paste in the XAML section a UIElement if you already have one.
3. In the same solution, add a new Windows Forms project (in VS2008 target v3.0 or v3.5).
4. From this winforms project add a reference to the WPF User Control project
5. Rebuild all.
6. With the Form1 designer open, open the toolbox and find the UserControl1 that you created (in WPF).
7. Drag it onto the Form1, resize to your liking (it doesn't have to be docked and can coexist with WinForm controls on the form).
Notice how what it effectively did is create an ElementHost for you and set its Child property to the UserControl1? When it adds the ElementHost, it also adds references to the WindowsFormsIntegration, PresentationCore, PresentationFramework, WindowsBase and UIAutomationProvider assemblies. You can repeat the exercise by replacing step 7 with manually dragging an ElementHost onto the form and then using the ElementHost Tasks popup to select the hosted content:

8. Ctrl+F5
9. Exercise for you dear reader: Follow the links above and see what cool sample you can come up with ;-)

FxCop rule for red bits

Wed, October 3, 2007, 04:43 AM under Orcas | VisualStudio
In my sessions I always explain the red and green bits story and then focus on describing the enhancements in the green bits – after all that is what people want to hear when attending a session on .NET Framework v3.5. I also make it clear that if you upgrade your projects to VS2008, you can leverage multitargeting to continue to target Fx v2.0.

Take those statements and combine them with my blog posts on the red bits (e.g. start here with this one). It should quickly become obvious that there are few little obscure additions at the public API surface level of v2.0 that, if you do take advantage when targeting v2.0 from VS2008, will result in your code crashing when deployed to a machine that only has v2.0 without the updates. That was a long sentence so feel free to re-read it ;).

The way Krzysztof describes it:
"But now I have to confess, there are some limitations in this design that we accepted when we made the original simplifying assumption. There is a very limited number of APIs being added to the Red assemblies and the multi-targeting system is currently not able to detect these."
To download his FxCop rule that addresses the deficiency in the VS 2008 multitargeting system for this niche scenario, visit his blog post. Note that even if you do not have VS2008, you can still download his Test.csproj and try to build to see the compiler errors in VS2005 on types/methods that do not exist. Go.

By the way, on a not so unrelated note, I found an interesting post which explains why previous versions of Visual Studio only targeted one framework version. Thought I'd share.

Video on Partial Methods in C# and Visual Basic

Fri, September 28, 2007, 01:30 AM under Orcas | VisualStudio
Recently I published a 15' video on a new VB9 and C# 3.0 language feature that is of course usable by projects targeting Fx v2.0 as well. The feature is called Partial Methods (not to be confused with extension methods).

Watch the screencast here.

Multithreaded Debugging Enhancements in Visual Studio 2008

Tue, September 25, 2007, 05:51 AM under ParallelComputing | Orcas | VisualStudio
Rather than writing or screenshoting the new multithreaded debugging enhancements in Visual Studio 2008, I thought I'd create a 15' video to demonstrate them. See if you can spot what the bug is before I "discover" it in my demo ;-).

Video: Build UAC aware apps with VS2008

Thu, August 23, 2007, 04:22 PM under Orcas | VisualStudio | UAC
One of the improvements in Visual Studio 2008 for building Windows Vista applications that work correctly with User Account Control is the ability to embed manifests in Visual Basic and C# projects. Watch my 15' video to see how.

Video: VS2008 Aesthetic and Usability enhancements

Wed, August 22, 2007, 12:54 PM under Orcas | VisualStudio
If you ignore the framework and compilers, then what is new in Visual Studio 2008 purely from an IDE perspective? Find out in my 10' video here.

Office projects require NETFX 3.5

Sun, August 19, 2007, 09:25 PM under Orcas
If you try to use VSTO v3 in Visual Studio 2008, you'll notice that the project templates are only available when you select .NET Framework v3.5 (via the multitrgeting feature). You'll probably ask yourself "why?".

The answer becomes obvious when you realise that the MAF (part of Fx 3.5) is actually an evolution of the add-in infrastructure used by the Visual Studio Tools for Office team. They worked on this initially and in the 3rd iteration handed it to the CLR team so it could be baked for public use, not just private use by the Office add-ins. So, now they still depend on it of course which is why the VSTO redist depends on Fx 3.5. They also took further dependencies on some of the new security bits in System.Core, WindowsBase in Fx 3.0 for the packaging APIs and some other less major things. Now you know ;-)

NETCF Beta 2

Sat, August 18, 2007, 06:49 PM under MobileAndEmbedded | Orcas
I got asked about new things in .NET Compact Framework 3.5 with the VS2008 Beta 2 release. Well, the NETCF team did all their good work very early on so there aren't any new features in this drop. Tons of new stuff compared to v2.0 of course, see my previous posts starting here.

In Beta 2 of NETCF 3.5 compared to Beta 1, I observe a couple of classes gone from the WCF stuff, some refactoring in System.Xml.Linq and some changes to mirror the System.Core changes I mentioned here in the 1st paragraph for the full framework.

The only major change is that the DataSet extensions have been factored into their own assembly: System.DataSet.Extensions.dll. This again mirrors the full framework implementation but internally the classes are not in sync yet. They will be by RTM, so my suggestion is to explore the LINQ to DataSet on the desktop, and use the same skills/code when it finally makes its appearance in the NETCF as well.

VS 2008 Tools menu

Fri, August 17, 2007, 08:16 AM under Orcas | VisualStudio
I opened the Tools menu of VS2008 Beta 2 and observed three changes compared to Beta 1. Can you spot them without reading beyond the screenshot:

(Obviously the "Upgrade Visual Basic 6 Code..." is not available in C# projects but everything else is the same in C#)

That's right:
1. The "Device Emulator Manager" moved up next to the other Device options.
2. There is a new menu item "Partner Product Catalog" which seems to open a web page with VSIP members.
3. The "WCF SvcConfigEditor" is back. For more on this configuration editor tool visit the relevant msdn page.

.NET 3.5 video

Thu, August 16, 2007, 06:09 PM under dotNET | Orcas
Want a lightning quick tour of the complete list of .NET 3.5 assemblies and where to find them? Wanna know how I personally explore new DLLs? Watch my 14' video here.

Watch my video on VS2008 multitargeting

Thu, August 16, 2007, 02:35 AM under Orcas | VisualStudio
Soma writes about one of my favourite features of Visual Studio 2008 (that is actually an msbuild feature). If you want to see it in action, watch the 15' video I recorded last week on channel9.

LINQ to SQL in Beta 2

Wed, August 15, 2007, 10:56 AM under Orcas | LINQ
LINQ to SQL has had some positive changes in VS 2008 Beta 2.

The most significant is that it is now faster (for background to this, see Rico's post) and has numerous bug fixes. Another very visible change is that for customisation, partial methods are utilised everywhere (LINQ to SQL was one of the drivers behind that feature). An aesthetic tool change is that when you map your database to the auto generated classes, you do not add a "LINQ to SQL File" item, instead you add a "LINQ to SQL Classes". It also has a much more professional icon rather than the old one that looked like it was drawn by... me! Here is the new one:


Opening System.Data.Linq.dll in your favourite dissasembler will reveal quite a few refactorings, but instead of looking inside out, I'll hand it over to Dinesh that has a fuller change list.

Visual Basic video

Tue, August 14, 2007, 05:49 PM under Orcas | VisualStudio
I recorded a 13' video on the improvements in VB intellisense (codenamed "intellisense everywhere") with VS2008. For more context and to watch it go here.

NGEN perf boost in red bits

Tue, August 14, 2007, 01:27 PM under dotNET | Orcas
One of the fixes to the updates for CLR v2.0 (that we will receive when Fx 3.5 ships) is ngen performance improvements (inc. for WPF assemblies). Read the full story here.

VS2008 supports Restart Manager

Tue, August 14, 2007, 03:15 AM under Windows | Vista | Orcas | VisualStudio
Two of my favourite new APIs of Windows Vista are: restart/recovery and Restart Manager.

I mentioned in passing that Orcas March CTP supported the restart API. I haven't had a chance to test if that area has been improved because I can't get Visual Studio 2008 Beta 2 to crash! If you have a repro case that crashes Beta 2, please let me know how.

How about Restart Manager support by Visual Studio 2008? I had tested this with Beta 1 and the answer was "no". Tested it with VS2008 Beta 2 and the answer is a resounding "yes". Not only it supports RM for being gently shutdown, but it actually does the right thing when it is restarted which is to auto open the solution you had open even down to the file you were viewing! If you had a file unsaved, it will prompt you on restart if you'd like to recover:


To see the RM functionality with VS2008 in action on your Vista machine running Beta 2, one easy way is to download my Vista demos, locate the project in the folder "RestartManagerSimulator", build it and then execute from the Debug folder the executable: RestartmanagerSimulator.exe. You should see an app that looks like this. In the textbox enter "devenv" (without the quotes) and hit the buttons in order: "Supports Restart?", "Register" and "Shutdown". Wait while that operation completes and Visual Studio exits. Then click on "Restart" and watch the magic happen ;-)

SortOrder in item VS2008 templates dialog

Mon, August 13, 2007, 07:37 AM under Orcas | VisualStudio
One of the annoying things of Visual Studio 2005 is that when you try and add a new item to a project the templates are listed in non-alphabetical order and there is no way to change that from the GUI. There are a couple of workarounds for VS2005 (e.g. see links from here), but they involve more work than to my liking.

Visual Studio 2008 improves the story by (almost always in Beta 2) sorting alphabetically :-)

Nice! The same is partially true for the New Project dialog. Also, as an added bonus, both of these dialogs are now resizable as the screenshots prove ;-)

Relaxed Delegates

Sun, August 12, 2007, 10:53 AM under Orcas | VisualStudio
I knew about covariance and contravariance that we got in the .NET 2.0 timeframe and I also knew that VB 9.0 (shipping with Visual Studio 2008) would fully support the feature and even enhance it. I hadn't appreciated how much it would be enhanced until I accidentally run into it yesterday (while recording a video on VB intellisense improvements).

I created a thread and had the delegate point to a method that I had already written. So I went to change my method to accept the Object as an argument and before having a chance I noticed that VB's background compiler hadn't complained about it!? In case you haven't guessed it by now, in VB9 you can omit the parameter list of a method pointed by a delegate, if you wish ;-)

Example:
' No need to type (s As Object, e As EventArgs)
Sub Button1_Click() Handles Button1.Click
Dim t = New Thread(AddressOf MyWorkerMethod)
t.Start()
End Sub

Sub MyWorkerMethod() 'No need to type (o As Object)
'Do sth on worker thread
End Sub

Read more about relaxed delegates on msdn (bottom of the article). Like with all other language features, you can use this one in your .NET 2.0 projects in VS 2008.

prop snippet

Sat, August 11, 2007, 02:24 PM under Orcas | VisualStudio
Hot on the trails of the improvement in the foreach code snippet in VS2008, I found that the prop snippet also changed:

Yup, automatic properties by default ;)

Changes in the red bits

Fri, August 10, 2007, 09:49 AM under dotNET | Orcas
I thought that Scott was trying to steal my thunder with his post about changes from v2.0 to v3.5, but instead he is focusing on the changes in the red bits and not the green bits – thanks! As a reminder the red bits are the same version.

He used libcheck to generate the report. Time for my confession: I have modified libcheck so it works for the .NET Compact Framework and indeed that is what I use to blog here about NETCF changes between v2.0 and v3.5. You can see a very old report of that tool when I was blogging about changes between NETCF v1.0 and NETCF v2.0 RC. I was going to use libcheck for reporting on the red bits, but never found the time to unearth an XP installation with v2.0 RTM on it – shocking I know :-).

I went through the report and other than the obvious additions in the GC the only other change worth talking about is DateTimeOffset which has had a ripple effect to other areas (e.g. XmlConvert.ToDateTimeOffset). Of course, most of the changes to the existing red bits are bug fixes and perf improvements so API differencing will not surface those. An example of an internal change the report will not show is the use of the Vista CommonFileDialog.

Anyway, check out the report on Scott's blog.

VS 2008 SKUs

Fri, August 10, 2007, 04:06 AM under Orcas | VisualStudio
With Visual Studio 2008, like with VS2005, we have the 4 Express Editions (C#, VB, C++, Web) and we also have the Standard and Professional Editions as well. PRO is what I typically use and, with VS2008, PRO now includes support for Unit Testing.

We also have the Team System Editions (Architect, Developer, Test, Database) inc. TFS and Test Load Agent, of course. With VS2008 the names for these have been rationalised and simplified. I may do a post in the future summarising the new stuff in VSTS 2008 (for now, you can view the complete feature list for TFS 2008).

There is also a new kid on the block. I am personally very excited about this and have added to my TODO tome to put aside some time to play with it: Visual Studio 2008 Shell (and its free!).

LINQ samples

Thu, August 9, 2007, 12:57 PM under Orcas | LINQ
I opened the Help menu of Visual Studio 2008 Beta 2 and observed three additions compared to Beta 1. Can you spot them without reading beyond the screenshot:


That's right:
1. MSDN Forums – browses to the MSDN forums.
2. Report a Bug – on my machine takes me here.
3. Samples – opens an htm file from your machine.

That last one is the most interesting to me. It includes hyperlinks to many sample projects on your machine. Clicking on "Visual C# Samples" will open a ZIP file that has two folders in it, one of them called "LinqSamples" that contains the BuildSamples.sln. Open that and you'll have 15 very interesting projects.

Included in that solution (no need to download anything from the web, contrary to following links) is the Paste XML As XElement add in project, the LinqToSqlQueryVisualizer debugger visualizer project and the ExpressionTreeVisualizer debugger visualizer project. Also, worth the admission fee alone is the SampleQueries project with literally hundreds of sample LINQ to everything queries in a format that you can learn from:

Go explore now!

STL to CLR

Wed, August 8, 2007, 01:56 PM under dotNET | Orcas
I have updated my Fx 3.5 list of dlls with one more: Microsoft.VisualC.STLCLR.dll.

As its name suggest, this is an assembly for C++ developers. To be clear, it is of no use to C#/VB developers since it is unusable without including the STL/CLR header. The idea is that if you are comfortable with the C++ Standard Template Library (STL) then you can still use the STL from your C++/CLI code. At the same time, it lets you port your existing unmanaged C++ that has investments in STL, to managed C++ without having to re-implement the STL portions – they just work since the STLCLR collections are compatible with the Generic .NET Collections!

For slides, demo and to read more about this assembly, please visit the STLCLR category on Nikola's blog. He has also recorded a video explaining everything about it.

ASP.NET 3.5 controls

Tue, August 7, 2007, 07:26 AM under dotNET | Orcas
In addition to infrastructure improvements to better support IIS7, and in addition to toolset enhancements, web developers get 3 new controls in ASP.NET 3.5 (specifically in System.Web.Extensions.dll and specifically in the System.Web.UI.WebControls namespace): ListView, DataPager, and now in Beta 2 we see for the first time LinqDataSource.

To read about ListView and DataPager go to Rick's blog and for LinqDatasource see Scott's blog. In addition to those 2 blog posts, Dan has two excellent videos showing off the controls here and here.

LINQ to SQL pipeline

Mon, August 6, 2007, 03:23 PM under Orcas | LINQ
Stumbled upon a great video of Matt Warren (questioned by Luca Bolognese and shot by Charlie Calvert) explaining the pipeline of LINQ to SQL i.e. it assumes you know how to use LINQ to SQL already and builds on that to explain the internals. Watch it here.

foreach uses var

Mon, August 6, 2007, 04:32 AM under Orcas | VisualStudio
Whenever I want to loop through a collection of some sort, in C# I type foreach and hit the TAB key twice (to invoke the code snippet). This gives me the following code template:
    foreach (object var in collection_to_loop)
{

}
...where object is highlighted so you can change it to the real type of your collection, var is highlighted so you can change it if you wish to have your own variable name and collection_to_loop is highlighted so you can change it to your actual collection variable name.

This always looked awkward to me when playing with LINQ since I typically use the keyword var to replace the object and then immediately I am confronted with var as the variable name that I change only so the awkwardness can go away.

In Visual Studio 2008 Beta 2 you get the following with the foreach code snippet:

No awkwardness, automatic use of local variable inference and, generally speaking, only one item to replace: collection.

Are you revisiting your own code snippets making them more user friendly?

Extension Members in Object Browser

Sat, August 4, 2007, 05:08 PM under Orcas | VisualStudio
Recall the new C#3 and VB9 language feature extension methods? Well, if you go into the object browser in Visual Studio 2008, there is an option to display extension methods for the chosen class. The following screenshot depicts that for the XElement (from XLinq):

Nice! The 3 extension methods (Validate and GetSchemaInfo) are actually defined in the static System.Xml.Schema.Extensions class, but still show up where we'd expect them to.

The above screenshot is in a VB project and I cannot get this feature to work reliably for me in C# projects yet. The option is there in both projects, but the result isn't. Here is how you enable the feature btw:

Go check it out...

Partial methods

Fri, August 3, 2007, 02:41 AM under Orcas | VisualStudio
With VS2008 Beta 2, we all get a chance to play with a feature that the product teams have been teasing us with by talking about it before it was available in public drops.

[Request to product teams]If your feature is not baked in public bits, please refrain from blogging about it; also please stop posting images of private bits.[end request]

The feature in question is Partial Methods. Wes has an excellent write up here from a C# perspective (that he followed with this) and Scott here from a VB perspective. I suggest you read both since at the conceptual level they are the same. Essentially it is an aid to code generation scenarios in the same way that partial classes are. Think of it as a combination of a more efficient version of private event handlers and the Conditional attribute. Read the previous links for the full story.

My take? I simply thought I'd see the feature in action so without referring to the posts or documentation I fired up Visual Studio to try it out from memory. How mistaken I was. Every time I tried something I was greeted with a compiler error pointing out my ignorance. I was going to post here the series of compiler errors I dealt with one by one until I managed to get the thing to compile, but instead I've tried to summarise a few of them with one line of code:

public partial bool GoGoGo(out int i); //produces the following Error List


What better way to learn than by the compiler teaching you... a bit like how kids learn that fire is hot... by touching it (well, that's the way I learnt anyway). If however you prefer reading a very long thorough post covering a feature (in addition to the 3 posts above by the product teams) and also prefer looking at things through ildasm, then head over to Bart's blog post on the topic.

More VS2008 UAC integration

Thu, August 2, 2007, 04:12 PM under Orcas | VisualStudio | UAC
I've shown before one example of VS2008 integrating nicely with UAC, but today I found another one:

The above dialog appeared after I tried creating a new SharePoint Workflow project. After selecting the "Restart" option, Visual Studio closed, I confirmed the UAC Consent dialog and VS then reopened elevated (with the title bar showing its mode) in the same state it was before.

If you find any other examples of actions that result in an elevation prompt in Visual Studio 2008, please drop me a line (other people collect stamps, I collect UAC screenshots).

UAC Settings in VB

Thu, August 2, 2007, 02:32 AM under Orcas | VisualStudio | UAC
Regular readers of my blog will know that a requirement (and more importantly good common sense) for your applications that will run on Vista is that they have an embedded manifest declaring their requested privilege for working better with UAC. With Beta 1 of VS2008 I showed how this has become a doddle for C# projects. At the time, there was no such easy option for VB projects.

With Beta 2, VB also gets an easy way to do this. If you find the GUI of the C# approach confusing, then you'll be pleased to find that the VB approach is a single button named View UAC Settings, as per the following screenshot:

Clicking on it adds a pre-populated manifest file to your project which you can optionally further tweak to your liking, of course.

Note that in C#, you can manually add Application Manifest Files yourself:

...and switch between them from the IDE. This does not seem possible from the GUI provided by the VB team.

Further note that this feature is obviously applicable for v2.0, v3.0 and v3.5 client project templates in both languages. My advice to you is to open all your client projects in VS2008 and embed the default manifest now with no further thought. Later you can determine if you need to tweak things...

Tool to collect VS2008 and Fx 3.5 setup logs

Wed, August 1, 2007, 10:23 AM under Orcas | VisualStudio
My Beta 2 installation experience was fine and dandy, but yours may not be. If you do face any issues, Aaron shows you how to collect the setup log files for diagnosing.

Unrecognized tag prefix or device filter 'asp'

Wed, August 1, 2007, 03:25 AM under Orcas | VisualStudio
If you are facing the error above with Beta 2, it is due to the changes I blogged about. Doug has a nice step-by-step investigation and the solution.

VSTO for VBA developers

Wed, August 1, 2007, 01:23 AM under Orcas | VisualStudio
A few months ago I posted about Office as a development platform with VS2008. While most of the features are easy for you to explore given the screenshots I posted, on my point 6 I only mentioned VBA<->VSTO interop with no further info. If that feature floats your boat (and it certainly will if you have existing VBA investments and would like to extend them with managed code), then go watch this 8' screencast on channel9 (or this soapbox video here).

There is also a great MSDN mag article on VSTO: Extend Your VBA Code With VSTO. It talks about VSTO and VBA interop in this section, and it also touches on ClickOnce deployment in this section.

Finally, relevant to the above, I thought I'd share a new (to me) acronym that I picked up this month: OBA (Office Business Applications).

LINQ's relationship to the new language features

Tue, July 31, 2007, 03:43 AM under Orcas | VisualStudio | LINQ
If you are interested in understanding the relationship of the new C#3 and VB9 features to LINQ, then watch my 20' screencast and let me know there if you have any questions (unlike other videos, I advise you not to speed it up, because I speak very fast as it is ;)).

System.Core.dll minor changes in Beta 2

Mon, July 30, 2007, 04:28 PM under dotNET | Orcas
System.Core.dll (one of the new 3.5 assemblies) has tons of types as you'll recall, so I thought I'd see if anything changed between Beta 1 and Beta 2.

First, do not panic when you open up System.Linq namespace and you do not see the Func delegates. They are still in the assembly but they moved to the System namespace and they also have new friend delegates with various overloads called Action, which are the equivalent of Func but with no return type (all of those changes make perfect sense if you ask me).

The System.Management namespace (with the 20 types inside it) has been renamed to System.Management.Instrumentation. Do not confuse this with the separate, same named assembly that is part of Fx 3.5.

There have also been some small changes to the System.Expressions namespace so revisit your code if you were using those (typically for writing your own LINQ provider).

Finally, the BigInteger is still marked as internal so I personally am giving up hope of seeing it make a come back...

Version and location changes in Beta 2

Mon, July 30, 2007, 02:10 AM under Orcas | VisualStudio
With Visual Studio 2008 Beta 2 some (good) changes were made to the location and versions of the .NET 3.5 assemblies, which previously were quite inconsistent (two additions were also made and I updated the previous post with those).

The .NET folder under Windows (C:\Windows\Microsoft.NET\Framework\) does not include a build number in its name now, it is just "v3.5" (with Beta 1 it was "v3.5.20404"). If you had explicit references to that location (e.g. in code, config files etc) you will have to change them.

The file versions of the v3.5 assemblies is now 3.5 (that was not the case previously for all of them). They still differ slightly between them on the build number but at least most[1] of them are now in the same place and you can see that in the following partial screenshot of "c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\"


Now with Beta 2, the assembly version numbers are more consistent with each other (and different to the file versions of course). You can see those using your favourite disassembler, or simply via the VS references dialog:


As a reminder, to understand what each one of these assemblies offers, see my blog entry on the green bits.

[1] In the 3rd paragraph above I wrote "mostly" because there is one assembly that is not in that same place: System.DirectoryServices.AccountManagement.dll is one level up in the folder hierarchy (!). So to reference this one you have to browse explicitly to that path from the VS references dialog. Its file version number is consistent with the rest (3.5.20706.1) and its assembly version is 3.5.0.0

Organize Usings in VS2008

Sun, July 29, 2007, 12:06 PM under Orcas | VisualStudio
In my demos you will never find superfluous using statements at the top of code files. When I am trying to explain some new API, I want it to be very clear what namespaces are being used. I have seen many other presenters that leave in there every namespace under the sun and it always annoys me. The other thing I try and do is remove references to assemblies that I am not using (for the same reasons). In fact, I used to do both of these even in real projects; even though there are zero performance implications for either, it just felt cleaner to me.

Now with VS2008 the manual process of removing namespaces is taken care for you. Simply right click in a code file and you see a new option as shown here:


Great! I am not so sure about sorting though. It sorts alphabetically and perhaps that is a good idea now that I think of it, but I am used to sorting my namespaces by length from shortest to longest so a nice triangle is visually formed (yes, I am weird, I know). More seriously, I usually just leave the last namespace I imported appear at the bottom of the list...

The sad thing is that this feature only takes care of using statements and NOT of assembly references as hinted in my opening paragraph. The ironic thing is that while this is a new C#-only feature, in VB (even with VS2005) you can indeed remove unused assembly references from the project properties. If only the two teams talked to each other and both decided to implement the other's complementary feature...

Open Beta 1 solutions with Beta 2

Sun, July 29, 2007, 10:11 AM under Orcas | VisualStudio
One of the annoying things on my machine after installing Beta 2 was that my existing Beta 1 solutions would not open by double clicking on them. I could open them from within Visual Studio and I could open project files by double clicking on them, but not sln files created with Beta 1.

If anybody else is facing this, my solution (pun not intended) was to open the solution file in Notepad and change the second line from:
# Visual Studio Codename Orcas
to
# Visual Studio 2008

If only everything was this simple...

Allow app to host WPF add-in

Sat, July 28, 2007, 03:03 AM under dotNET | Orcas
I noticed a new green assembly has been added to Beta 2 of .NET Framework 3.5: System.Windows.Presentation.dll.

Curiocity got me digging and it appears that it adds some infrastructure support in order for the Managed AddIn Framework (MAF) to work with WPF apps... FYI, also mentioned here.

VS2008 Installation experience

Fri, July 27, 2007, 03:49 AM under Orcas | VisualStudio
Before installing anything these days, I always explicitly run Windows Update. The last thing I want is for an update to kick off in the middle of an install. I encourage you to do the same!

My first attempt to install Beta 2 Professional edition was to be optimistic and install it over Beta 1 on my Vista machine. This dream ended as soon as I run the setup:

So I went to the "Programs and Features" page in control panel and removed "Visual Studio Codename Orcas", which removed a whole bunch of other related things. I then run the setup again and life was good:


After clicking "Install" on the dialog above, the first item that the setup tries to install is .NET Framework 3.5. This took absolute ages on my machine (over 10 minutes). Midway through it was obvious that it had invoked Windows Update because Windows Update gave me the message that it wanted to restart my machine. I thought I'd play it safe (and advise you to do the same) so I selected "Postpone for 4 hours" on that dialog. I then waited and eventually the VS2008 setup informed me that a reboot was required. Of course, I accepted that one. After Vista rebooted the setup continued automatically with no intervention on my part. Apparently, some people (without admin accounts) have to start it manually again so your mileage may vary.

So what was the Windows Update thing that was invoked by the setup, especially since I had manually run windows update before? That is the Service Pack 1 for v2.0 and v3.0 of the .NET Framework (fyi, explanation of red bits). The setup knows where to go and look for them and right now they appear as hotfixes: KB929300 and KB110806.

After that, the rest was as smooth as peanut butter (the smooth variety, not the chunky one).

LINQ to DataSet

Thu, July 26, 2007, 06:52 PM under Orcas
Another LINQ implementation that will ship with Fx 3.5 is LINQ to DataSet (not to be confused with LINQ to SQL).

LINQ to DataSet is about offering a strongly typed in-memory query language for DataSets - it is not for creation of DataSets or for smoothly updating the back end. So, if you are already using DataSets in your applications (inc. mobile applications), keep on reading.

If you tried LINQ to DataSet before Beta 2, then you had to reference System.Data.Entity.dll. This assembly is where the new Entity model lives, which will not ship at the same time as VS2008, but instead will ship soon after. Since LINQ to DataSet will ship with VS2008, its implementation had to be relocated. Its new home is System.Data.DataSetExtensions.dll (and it has a bunch of new types and members compared to the pre-Beta2 implementation!).

In this new assembly you will find a single namespace (System.Data) that contains a total of 9 types. Of these 9 types, 6 are used by the infrastructure and are not intended by direct explicit use by you. I have captured these 6 in this class diagram here. Now, think about what you need in order to use the LINQ syntax with the DataSet... not much really. Since DataSet is an in-memory object, the existing implementation of LINQ to Objects is heavily leveraged. However, in order to make things as friendly as possible, some helper intermediate types are used when we compose our queries and when generating strongly typed datasets – as application developers we don't have to worry about them. These intermediaries is what the previous class diagram shows.

When typing your LINQ queries, you have to sometimes convert from the types that the DataSet uses (e.g. a strongly typed DataTable) to types that LINQ likes using (e.g. IEnumerable). Combine that point with the fact that your queries are likely to be at the DataRow or DataTable level and you realise that what you need is some extension methods to help. That is what the remainder 3 types in the assembly are there for, and you should familiarise yourself with those extension methods to make the best of LINQ to DataSet. Use the following class diagram as food for thought before delving into the code:

For example, calling AsEnumerable on a DataTable makes it fit and compile under the query pattern. For example, calling AsDataView on the results of a query, gives you something you can databind a grid with, make changes and then use for updating the back end (a bit of a roundabout way, but it works). For example, rather than use strings and casting and have to deal with nulls at runtime, you can use Field to do the casting for you and convert to a nullable type. See the following quick example that assumes you have a dataset with data and a datagridview on a form:
var results = 
from o in dataSet1.Tables[0].AsEnumerable()
where o.Field<string>("City" ) == "Hove"
select o;

dataGridView1.DataSource = results.AsDataView();

For more background on LINQ to DataSet, see this 3-part series written on the ADO.NET blog back in February: Part one, part two and part three.

There is also a recorded webcast from May which you can view on-demand here. The first 3 minutes are good for setting the scene of why LINQ-enabling the DataSet is important. The following 17' is a generic intro to LINQ so if you are familiar already feel free to skip. From the 20th to the 40th minute are 3 demos where you can see it in action. I'd suggest stop watching after that (i.e. miss the 4th demo) because the feature it shows is not implemented like that in Beta 2 and later. To get the 3 aforementioned demos, visit Erick's blog (and stay tuned there for updates to the LINQ to DataSet story).

VS2008 Beta 2 with go live license

Thu, July 26, 2007, 02:23 PM under Orcas | VisualStudio
The moment we've all been waiting for: Visual Studio 2008 Beta 2 hits the streets so get it now

This one has a go-live license associated with it which means that the team are confident about the quality of the product and also about the final feature set. Apparently, you will be able to go smoothly from this version to the RTM version later this year. All changes between this one and the RTM version will be documented, they say. What I can tell you from personal experience is that this build is very solid and has not malfunctioned on me once in the last X days that I've been running it.

You have no reason to wait any longer, go download it and start using it for your existing v2.0/v3.0 projects and later consider taking advantage of the new v3.5 features. Remember, VS2008 has everything in the box :-)

Class Designer for C++ in VS2008

Mon, July 23, 2007, 01:54 PM under Orcas | VisualStudio
One of my top 3 favourite features when VS2005 came out was Class Designer (blogged about it 3 years ago). With VS2008, I cannot say there are major enhancements for the Class Designer, but now it is partially supported for C++ projects as well. The team is asking for your feedback so go give it while it's hot.

VS2008 integration with UAC

Wed, June 20, 2007, 02:52 PM under Orcas | VisualStudio | UAC
You know that when you run VS2005 on Vista (even with SP1 and the SP1 update) you get advised to run elevated. You also know that VS2008 has better indication when you run it elevated.

What I haven't explicitly stated before is that VS2008 does not require you to run it elevated from the start. Instead it is a good Vista client and plays nicely with UAC by only prompting you to restart the IDE when you truly need to. For some type of projects this will equate to always run elevated of course, but it is good that it doesn't force this behaviour on all of us and that it offers to do it for you as needed.

Recently I discovered one scenario where it plays nicely. I double clicked on a solution file in explorer and because it was in a place requiring admin rights, I got the following dialog from VS2008


This is cool (even though I suspect the final text will be slightly different as there are a couple of errors there e.g. UAC = User Account Control).­­­­­­­­­­­­­

.NET Framework 3.5

Tue, June 5, 2007, 04:17 PM under dotNET | Orcas
This is a follow up to my previous description of putting VS2008 in context.

.NET Framework (NetFx or Fx) version 3.5 has two elements to it that must be understood: the green bits and the red bits. The original references to this term are on old blog posts by Soma and Jason. Compared to those two blog entries I have the advantage of 13 months of hindsight :-), so I will provide here the details behind those descriptions in my own words starting with my own slide:


When we say red bits, those are Framework bits that exist in RTM today i.e. NetFx v2.0 and NetFx v3.0.

NetFx v3.5 includes updates for those two existing frameworks. However, those updates are not a whole bunch of new features or changes, but in reality a service pack with predominantly bug fixes and perf improvements. So to revisit the terminology: Fx 3.5 includes v2.0 SP1 and v3.0 SP1. Like with all service packs, there should be nothing in there that could break your application. Having said that, if a bug is fixed in the SP and your code was taking advantage of that bug, then your code will break of course. To be absolutely clear, this is an in-place upgrade to v2 and v3, not a side-by-side story at the framework/clr level. I will not focus anymore on the Service Pack (red bits) improvements in Fx 3.5. If you are interested in that you may wish to read my previous blog posts here, here, here and here.

When we say green bits, we mean brand new assemblies with brand new types in them. These are simply adding to the .NET Framework (not changing or removing) just like Fx 3.0 was simply adding to v2.0 without changing existing assemblies and without changing the CLR engine. It is here where you find the brand new stuff to talk about. In Beta 1, the list of new assemblies (green bits) is:

1. System.Data.Linq.dll – The implementation for LINQ to SQL.

2. System.Xml.Linq.dll – The implementation for LINQ to XML.

3. System.AddIn.dll, System.AddIn.Contract.dll – New AddIn (plug-in) model.

4. System.Net.dll – Peer to Peer APIs.

5. System.DirectoryServices.AccountManagement.dll – Wrapper for Active Directory APIs.

6. System.Management.Instrumentation.dll – WMI 2.0 managed provider (combined with System.Management namespace in System.Core.dll).

7. System.WorkflowServices.dll and System.ServiceModel.Web.dll – WF and WCF enhancements (for more on WF + WCF in v3.5 follow links from here).

8. System.Web.Extensions.dll – The implementation for ASP.NET AJAX (for more web enhancements, follow links from here) plus also the implementation of Client Application Services and the three ASP.NET 3.5 controls.

9. System.Core.dll – In addition to the LINQ to Objects implementation, this assembly includes the following: HashSet, TimeZoneInfo, Pipes, ReaderWriteLockSlim, System.Security.*, System.Diagnostics.Eventing.* and System.Diagnostics.PerformanceData.

UPDATE: Beta 2 added two more

10. System.Data.DataSetExtensions.dll – The implementation of LINQ to DataSet.

11. System.Windows.Presentation.dll –WPF support for the System.AddIn mentioned of point 3 above.

12. System.VisualC.STLCLR.dll – STL development in the managed world.

If you decide to "borrow" my slide above, feel free to do the right thing and point people back to this blog post ;-)

Visual Studio 2008 stack

Mon, June 4, 2007, 07:02 AM under Orcas | VisualStudio
When Visual Studio 2008 (formerly Visual Studio codename "Orcas") ships in FY08, we will also get other elements of the stack. Below is the opening slide I use at Orcas events:

The main points are that the CLR engine is the same version (so no need to retest your apps) and that the headline feature is the language enhancements (C#3 & VB9 compilers) and LINQ.

The VS2008 IDE is not as big a jump as it was when going from VS.NET2003 to VS2005 and it includes all of today's SDKs out of the box and also a simple yet sweet feature: multitargeting inc. the ability to use new language features from .NET 2.0 projects. FYI, I usually do a demo of new IDE features that lasts 15 minutes (inc. aesthetics, VB intellisense, embedding manifests and new Office templates). Given that VS2008 is a superset of VS2005, there is little point in having both of them installed on the same machine, but it is possible – we support side-by-side at the IDE level.

So that is the IDE, languages and CLR in a nutshell. How about .NET Framework v3.5? For that you'll have to see my blog post tomorrow.

DateTimeOffset

Sun, June 3, 2007, 05:00 AM under dotNET | Orcas
If you never liked the name of TimeZone2, you'll be pleased to know that in "Orcas" Beta 1 it was renamed to TimeZoneInfo. Having played with this a bit, I found that its members include a dependency on yet another new type: DateTimeOffset. I searched and saw that this has actually been in there for a while.

What I can't fathom is why DateTimeOffset ended up in mscorlib and TimeZoneInfo ended up in System.Core! The latter makes sense, it is a brand new type so it cannot go into existing bits; so why break that rule for the former? To be clear, I would expect both of them to reside in Core. Anyway, regardless of where they belong, go play with them ;)

Visual Studio Orcas SDK June CTP

Sat, June 2, 2007, 03:28 AM under Orcas | VisualStudio
Want to work with VS "Orcas" Beta 1 extensibility points? Get the SDK here.

Client Application Services in "Orcas"

Thu, May 24, 2007, 12:39 PM under dotNET | Orcas
I've had on my TOPLAY list to discover what the "Services" tab is for in the project properties for Orcas client projects. If you don't have Orcas installed and are wondering what's behind the "Advanced" button on that screenshot, it looks like this:


It turns out it is for a new feature, which you can read all about on MSDN, which we are calling "Client Application Services". This will be useful to you if in your smart client applications you want to authenticate users (inc. maintaining different roles and profiles) against a central web store (e.g. with webservices etc) including the ability to work offline once the user settings have been retrieved. It is particularly useful if you are using that central web store already for existing web applications because, as you may have guessed, it leverages the same ASP.NET 2.0 services for authentication, authorisation and personalisation.

The claim is that this Orcas feature makes it "trivial" to create the services on the server-side and to then consume them from the client-side. To see if this claim holds true for you, why not check out the walkthrough by Brad over here, inspired apparently from this one over here (both links include project downloads).

There is also an old webcast on the topic here (you can download the wmv), and I would suggest you skip the first 21 minutes of slides and go straight to the 30' demo.

Import namespace in VB9

Sun, May 20, 2007, 02:10 PM under Orcas | VisualStudio
A cute Whidbey feature in the C# 2.0 editor is that when you type in a Type that is not in scope, the IDE will let you choose to automatically either fully qualify the type or to add the appropriate using statement at the top. The editor for the VB8 experience is not that great, as shown by the following side-by-side screenshot:

BTW, for my C# readers, that is not a mistake, VB does allow partial naming of namespaces so since System is in scope, you can simply type Threading.Thread and it is acceptable. A bad habit IMO, I suggest as a guideline that you fully qualify the types starting at the root namespace.

Recently I was typing some VB9 code in "Orcas" and observed that the VB editor has caught up with the C# behaviour (plus it follows my guideline of the previous paragraph), as shown by the following screenshot:

Nice! And just like any other IDE language feature, it is not just for the latest version, but for the previous version as well (thanks to multitargeting).

System.Data.Linq.dll

Sat, May 19, 2007, 06:19 AM under dotNET | Orcas | LINQ
One of the green bit assemblies in .NET Framework 3.5 is System.Data.Linq.dll. As you may have guessed, this assembly contains the framework implementation for LINQ to SQL. Regular readers will know about my other multiple LINQ posts, but I have never posted about LINQ to SQL (formerly known as DLinq).

So, if you are interested in DLINQ, stay tuned on a series of posts that ScottGu has started here. For a detailed LINQ to SQL tutorial series of videos, check out the output from our local nugget machine (aka MikeT). I have captured here the direct links to the WMVs for the 18 screencasts: Intro, DataContext, Mapping, Tools, Inserting Data, Deleting Data, Updates, Concurrency, Joins, NULLs, Deferred Query Execution, Deferred Loading, Stored Procedures (querying), Stored Procedures (updates), Standard Functions, Custom Functions, Inheritance, Transactions.

Winforms 1 - WPF 0

Wed, May 16, 2007, 09:11 PM under dotNET | Windows | Vista | Orcas
Oh, how happy I was when Orcas started using the Vista CommonFileDialog. Oh, how pissed off I get when applications on Vista still use the old legacy dialog. One of the applications I use a lot is Reflector and for a while I've been nagging Lutz on IM and email to make Reflector use the new OpenFileDialog, but nothing came of my harassment. Until recently when I noticed that Reflector indeed started showing me the new dialog so I thanked Lutz for finally listening. His reply was that he wasn't aware of it and he had changed nothing other than it now forces it to run against 2.0.50727 using a config file. That put me on a hunt!

The result of the hunt was that with the "Orcas" update of v2.0.50727 (remember how I explained this a few hours ago) the System.Windows.Forms.OpenFileDialog has had an internal implementation change that makes it detect if it is on Vista and puts the correct dialog up, rather than the legacy one (on a legacy OS like XP, it will show the old dialog of course). Using reflector, the place to look is FileDialog.RunDialogVista called by FileDialog.RunDialog which is called by CommonDialog.ShowDialog. Great news!

So I then wanted to see if the WPF version has also been updated, in which case half of VistaBridge would be obsolete (the TaskDialog half would still be useful of course). Unfortunately, the WPF version of OpenFileDialog (residing in Microsoft.Win32 namespace in the PresentationFramework.dll) has not been updated. I am confident that it will happen by RTM, but in the meantime from your WPF projects you can reference the System.Windows.Forms.dll and use its Open/SaveFileDialog instead.

PerformanceData

Tue, May 15, 2007, 04:10 PM under dotNET | Windows | Vista | Orcas
One of the namespaces in the new System.Core.dll is System.Diagnostics.PerformanceData. It is a set of classes that wrap a new set of performance counter APIs (in Advapi32.dll) that are applicable only to Vista and higher. Here is a class diagram followed by an explanation:

Rather than actual code, here are the steps for working with the set of classes above.
1. Create a CounterSet object specifying the CounterSetInstanceType
2. On this instance, call AddCounter specifying an integer id and a CounterType (plus optionally a name) [repeat this step as desired]
3. Once done repeating step 2, call CreateCounterSetInstance to obtain a CounterSetInstance object.
4. On the object of step 3, via its Counters property get an instance of the collection object: CounterSetInstanceCounterDataSet
5. From this collection, retireve the CounterData objects either via the integer id or by name
6. Only one long Value property on the CounterData objects to tell you what you are after

In case you are wondering, step 1 above wraps PerfStartProvider and step 3 wraps three APIs in sequence: PerfSetCounterSetInfo, PerfCreateInstance and PerfSetCounterRefValue. If you look at the native signatures and the "cute" structures they expect you to setup, then you'll realise why it has been wrapped for us :-)

AccountManagement

Tue, May 15, 2007, 03:33 PM under dotNET | Orcas
One of the new assemblies in .NET Framework 3.5 is System.DirectoryServices.AccountManagement.dll (you have to browse on the file system to your Framework 3.5 installation in order to add a reference in VS "Orcas"). It is an extensible managed wrapper with intuitive search that aims to simplify programming with both ADAM and AD – it is based on SDS/ADSI under the hood. I deduced that from a powerpoint deck that you can find in a zip file if you scroll to the bottom of Joe's blog post there (look at slides 18-22, includes code snippets).

I started looking at it and like I always do with new namespaces I drew a class diagram to help me understand it. It turned out to be fairly large so only if you are really interested, have a look here. Better still, for a small piece of sample code, go to Bart's blog post.

Using Extension methods in Fx 2.0 projects

Sun, May 13, 2007, 03:30 PM under dotNET | Orcas | LINQ
For the importance and context of this blog entry, please DO read my previous blog post including the disclaimer at the top.

The feature I have not explicitly addressed yet is extension methods. If you are a C# developer that has been using the "magic" this keyword read my explanation to understand what we are talking about here. You see, even though extension methods are a compiler trick, they do rely on the new System.Runtime.CompilerServices.ExtensionAttribute introduced in System.Core.dll. Since we've already established that System.Core is a Fx v3.5 assembly and hence is not usable from 2.0 projects, you might think this is the end of the road for extension method usage in 2.0 projects. Let's explore this further.

In a 2.0 Orcas project try and compile the following code:
static class Program
{
//[ExtensionAttribute()]
static void DisplayInterval(this Timer t)
{
Console.WriteLine(t.Interval.ToString());
}

static void Main(string[] args)
{
System.Timers.Timer t = new System.Timers.Timer(2000);

Program.DisplayInterval(t); // long hand usage of method
t.DisplayInterval(); // short hand usage of method (extension)

Console.ReadLine();
}
}
You will see a compiler error as follows:
"Cannot use 'this' modifier on first parameter of method declaration without a reference to System.Core.dll. Add a reference to System.Core.dll or remove 'this' modifier from the method declaration"
What the compiler *really* wants to say is:
"You are using the 'this' modifier and it depends on the ExtensionAttribute that itself resides in the System.Core.dll and you do not have a reference to it"
Once you understand what it is really saying, and once you realise that it only needs this attribute at compile time (since at runtime the IL to be interpreted will still include the call to the utility method in long hand), then it all becomes clear what you need to do next. Declare the attribute yourself! It isn't such a big logical jump (or else I wouldn't have made it :-))

So add to your 2.0 project a new empty code file and paste in it the following code:
namespace System.Runtime.CompilerServices
{
public class ExtensionAttribute : Attribute { }
}
Then, wherever you declare the extension methods, optionally add to the top:
using System.Runtime.CompilerServices;
Now your projects will compile and you can use extension methods!

So summing up the previous post and this one, all 6 language features behind LINQ are usable from Fx v2.0 projects. But the LINQ to objects/xml/data implementations clearly are not usable because they live in Fx 3.5 assemblies. You can of course offer your own LINQ implementations for your own data sources. For example, the following code will compile in a Fx 2.0 project...
using Moth.Linq;
static class Program
{
static void Main(string[] args)
{
var ints = new []{1,2,3,4};
var res2 = from p in ints
where p > 2
select p;

System.Diagnostics.Debugger.Break();
// examine res2
Console.ReadLine();
}
}
...if you also add to the project this (demo) code file here.


BTW, how soon are you guys out there planning to move your existing 2.0 projects to Visual Studio "Orcas"? ;-)

Using C# 3.0 from .NET 2.0

Sun, May 13, 2007, 03:15 PM under Orcas | VisualStudio | LINQ
Please note that this and my next post are based on Beta 1 Orcas bits. Later builds might change the facts so always try it yourselves.

There still appears to be some confusion with regards to the new language features that make LINQ to objects work. In particular, there are claims that it all works with .NET 2.0 and counterclaims that it doesn't. IMO the confusion arises from people not being precise about what they are talking about. I'll try and give you here my view (which of course I think is as clear as can get :-))

To start with, everything here is in the context of Visual Studio "Orcas" – forget earlier versions. Orcas supports multitargeting so you can build projects that target .NET Framework v2.0. So the real question we are addressing here is whether you can choose to build a NetFx 2.0 project that also uses some of the new C#3 language features.

If you are not familiar with LINQ, please go read my detailed LINQ blog posts and then come back. So after reading about LINQ I hope you realise that:
LINQ =
1. local variable inference +
2. object intiliazers +
3. anonymous types +
4. lambda expressions +
5. extension methods +
6. query expressions +
7. framework support.

Let's look at some of the language features. The first 4 do work with 2.0 projects i.e. the following compiles and runs fine in a 2.0 Orcas project:
class Program
{
delegate T Func<T>(T t);
static void Main(string[] args)
{
// object init -
// makes no sense in this example but hey...
Timer t = new Timer(2000)
{
AutoReset = false,
Enabled = true
};

// local var inf, anonymous types
var i = new { Name = "Fred", Age = 6 };
Console.WriteLine(i.ToString());

// lambdas
Func<int> f = j => j + 1;
Console.WriteLine(f(5));

Console.ReadLine();
}
}
Can you spot them? Local variable type inference, object initiliazers, lambda expressions and anonymous types. This shouldn't surprise you if you read my previous blog posts since I have stated clearly many times that these language features are simply compiler tricks. The IL that gets generated is the same old IL – no dependency on the framework and no dependency on the runtime. So 2.0 projects in Orcas can use 4 of the smart compiler tricks, this is good! As an aside, other 3.0 compiler features irrelevant to LINQ such as automatic properties, also work in 2.0 projects.

On the gloomy side, it goes without saying that number 7 above, the "framework support", resides in System.Core.dll and you cannot reference that assembly from 2.0 projects, so no extension method implementations for you in 2.0 projects. If at this point we think of number 6 above, "query expressions" (i.e. from...where...select syntax), we realise that their usefulness is in friendly mapping to the extension method implementations in System.Core.dll (or System.Xml.Linq or Systam.Data.Linq or your own extension method implementations). So even though query expressions are supported when targeting v2.0 projects from VS "Orcas" (the syntax highlighting when you try it is a clue) there is no implementation to map them onto - other than your own. Well, even your "own implementation" implies that you can use Extension methods for v2.0 projects and I haven't addressed that yet (number 5 above). See my next post now.

System.Xml.Linq

Fri, May 11, 2007, 09:36 AM under dotNET | Orcas | LINQ
Part of .NET Framework 3.5 is a new framework assembly: System.Xml.Linq dll. Now, I know most people describe this in the context of LINQ (it used to be called XLinq) and indeed it works very well with LINQ but I wanted to stress here that effectively this is a standalone new XML API. You can use it without ever going anywhere near the LINQ syntax.

There are 3 namespaces inside the assembly the main one being System.Xml.Linq with 23 types, the most important shown below:

The ones you are most likely to use all the time are XElement and XAttribute (I bet you thought I'd say XDocument but actually you don't really have to use that one!). So why yet another new API for XML? Because this one is really cool! One aspect of the coolness is the way you create XML documents/fragments: You can do that in a single statement where the creation of XML items and their association takes place in the same step! Also while writing that single step/statement, you get to do it in the natural way that you think of the layout of the XML document. For example, in the following screenshot I have captured the code and the document it creates side by side. Can you see how intuitive it is?

Another aspect of the coolness of the API is that you can indeed use it with the LINQ syntax both for creation and for querying. To assist with that there are a bunch of extension methods in 3 static classes: System.Xml.Linq.Extensions, System.Xml.Schema.Extensions and System.Xml.XPath.Extensions. FYI, there are no other types in the Schema and XPath namespaces. I'll let you explore that yourself in the Beta 1 of Orcas.

The coolest thing about this API however is only available to Visual Basic developers. The VB compiler is smart enough to let you type in XML literals while it produces the necessary calls to the new XML classes. The code I showed above in C# 3.0 can be written in VB9 as per the following:

To see more about creating the documents, how LINQ syntax can be thrown in and how VB syntax with XML truly rocks you need some nuggets of course. Well, my colleague beat me to it so I encourage you to view his videos here (he is a bit behind the times using the March CTP so note that adding a reference to System.Core and System.Xml.Linq is done for you in Beta 1 for 3.5 projects).

Multitargeting

Fri, May 11, 2007, 09:30 AM under Orcas | VisualStudio
I have talked about and screenshoted multitargeting before in Orcas. When you create a new 2.0 or 3.0 project, features that are in v3.5 will not be available in your toolbox or properties or the references dialog. What I hadn't realised until today was that you can still see them even though they are not available, which I think is cool. Notice in the following screenshot how System.Core.dll is greyed out in my 2.0 project references dialog.

If you create a project and then change the framework you target to be a lower version than what it was before, you will get compiler errors for anything that isn't present, of course.

Repaving and how VS Orcas saves me time

Thu, April 26, 2007, 04:09 AM under Orcas | VisualStudio
Recently I repaved my Toshiba M5 starting from scratch (format, Vista RTM, join domain etc). The way this works for me is that I have a secondary drive in the laptop with all my data plus apps (multiple msi files, setup.exe files, iso images etc). I install the OS on the main drive and then continue to install the other applications from the 2nd drive. Looking at my instructions (I've written a simple installation todo.txt file that reminds me of what to do), I used to install the following for my mobile development needs: VS2005, SP1, SP1 Update for Vista, Latest NETCF SP, WM5 PPC SDK, WM5 SP SDK, DE v2. I am sure this isn't the story for device development only, but that every developer has their own set of things they install on top of VS e.g. WF Extensions, WPF/WCF extensions, VSTO SE, AJAX, MOSS SDK etc - overall a dozen or more separate installation packages (separate to install, separate to maintain/keep).

With the advent of Orcas Beta 1, I decided to ditch VS2005 completely and only install Orcas as my sole dev environment (btw, without multitargeting this decision would not be possible). It is only then that I truly realised that I do not need *any* of the above extras/extensions/SDKs since they *all* ship in the box as part of the single installation! :-)

The side benefit of this is that, previously if you had no interest in some technology (e.g. Office development or web development or device development) you probably wouldn't bother installing something separate, but now the story is different: it is just there so you can have a quick play with it whenever you want and ignore it thereafter if you still don't fancy it.

What will YOU install the next time you repave your machine: VS2005 side-by-side with Orcas or just Orcas?

Transparent Intellisense

Tue, April 24, 2007, 02:05 AM under Orcas | VisualStudio
While no doubt everyone will be talking about VB intellisense that I’ve mentioned before or the Javascript intelisense, I just discovered another small improvement in the Orcas IDE.

You will recall that VS2005 introduced DataTips (debugger tooltips on steroids) and when you hold down the Ctrl key they become transparent. Well, that is now true as of Beta 1 for the intellisense window too! In the screenshot below, the left side is what you would face today but with Orcas Beta 1 hold down the Ctrl key and you can see what is below the intellisense window without having to close it, as shown on the right:


I wonder how many people will discover that. It reminds me of another little known feature introduced in VS2005, which I still encounter people today not knowing about: ability to resize the intellisense window... try it if you haven't!

Orcas Office development through pictures

Sun, April 22, 2007, 12:02 PM under Orcas | VisualStudio
At this year's UK MSDN roadshow day (btw, next one is this Wednesday 25th) we have five 70' session slots. MikeT shared our reasoning for including a 10' office bit at the end of each core 60' session. Most of the people that I spoke to said that before the event they didn't care about Office development but after seeing how easy it is to do and realising the benefits, they have more of an open mind now. Given that it seems not so easy to find information on Office development, Martin did a great job pulling together starting points. Go check them out!

In "Orcas" the Office story gets even better:
0. Office 2003 and 2007 development out of the box. No need to download a separate VSTO (SE) SDK.

1. New project types. Now you can create out of the box add-ins at the document/template level, rather than just the global application level only. Feast your eyes on these project templates:

For Office 2003 project templates, see this screenshot.

2. Ribbon designer. No more manual authoring of XML, just drag and drop ribbon controls into groups on tabs, set properties and you are done (the familiar winforms paradigm).

In the image above you see properties for the button, but you can also tweak properties (and handle events) for the other ribbon elements (i.e. tab, group) including the ribbon itself such as its OnLoad event! If you right click on the ribbon in the designer you get the option to generate the XML (and cs) file - attendees of my roadshow session know XML was the only approach available with VSTO SE:


3. To customise the ribbon for any of the 2007 Office applications you have to select the appropriate item template from the Add New Item dialog:

If you created an Outlook project, as you can see the dialog above also offers the Form Region option. That's right, support for Outlook 2007 Form Regions is now available via Windows Forms controls (no more manual messing with OFS files) and the wizard even offers the option to import existing projects (this last option is not functioning yet in Beta 1):

Click for screenshots of STEP 2 and of STEP 3.

4. From the first screenshot of this blog post you saw that we can create document and template level projects for Excel and Word. Picking any of those leads you to a dialog similar to this:

After that you can add new document level Actions Pane items (don't confuse with Custom Task Pane which works at the application level and is just a UserControl):

Specifically for Word projects, in design mode in VS you can add to Word's surface (and even databind!) Content Controls:


5. Even though all of the above is Office client-side, under the Office banner we include the server-side technology SharePoint. Authoring workflows for SharePoint in VS2005 involves a 15-step configuration process (which some of you will have seen me perform for the UK developer launch of Office in January :-)). In "Orcas", you simply design the workflow and hit F5 including easy debugging. The complex stuff is taken care of by a wizard, whose first step you can see here:


6. Naturally I don't have teaser screenshots for every Orcas Office feature so I leave it to you to discover the interoperability between VSTO/VBA (i.e. call the former from the latter), support for the new Office file format and ClickOnce improvements...

In short, with VS Orcas and Office 2007, I am finally beginning to see the meat in the phrase: "Office as a development platform"...

In addition to the links at the top, you may find interesting these Office blogs here, here, here, here, here and here.

VB intellisense in Orcas

Fri, April 20, 2007, 06:49 AM under Orcas | VisualStudio
From the first time I typed Visual Basic code in Orcas I've had on my list to do a short video to show the new and improved intellisense because only video can do it justice. Since Amanda let the cat out of the bag by posting some screenshots, I am left with no choice but to share even more of the intellisense story with you :-)

Basically, it is everywhere. When you start typing "D" to declare/dimension a variable, it will pop up:

...when you then continue to declare the type of the variable, it will help you again:

...it comes into its own with the new LINQ syntax:

...and at the end of code line, when you press the spacebar, it will even prompt you for the continuation line:


You just have to go type some VB code in Orcas to truly appreciate how helpful it is. However, the killer for me is what I will refer to as "member filtering" as I have no idea what the official name is. With this feature, after hitting the dot (".") on a class variable and as you type, the intellisense window filters down to the more appropriate member. See the following 3 screen captures that I combined into one screenshot image:



In the example above, first we have the list of all members of the Process class, then after typing "p" the list gets filtered down to only members starting with p and then finally when we type "ro" the list goes down to just the two members starting with "pro". If I continued typing when I reached "n" in "ProcessN" I would have been left with just one member.

And all this great intellisense is of course also available when targeting .NET 2.0 projects (minus the LINQ stuff) due to the Orcas multi-targeting.

Aesthetic and usability in Orcas B1

Fri, April 20, 2007, 05:15 AM under Orcas | VisualStudio
After installing Beta 1 on my Vista machine, I found that the look and feel of things I previously blogged about had changed for the better.

* Ctlr+Tab got a facelift. For previous screenshot and the new one see my updated blog post: Ctrl+Tab in Orcas.

* The ability to target multiple framework versions from a single IDE is still there but now it is more obvious (they must have heard my winging :-)). Check out my updated post on Multi-targeting.

* For Smart Device Projects, I complained about the combobox not remembering the selection and now that is fixed. The VSD team also added a bonus feature in this release. Check out my updated post on the new Project Dialog.

* Like in previous builds, we have nice rounded selections in the menus...

...if you complete the action of the screenshot above, you will of course get this dialog. Notice how the treeview under Project Types displays no plus/minus for expanding/collapsing the nodes? If however you hover the mouse on the treeview then new triangle expandos appear as per the following screenshot:

For more on what is going on here read my post on TreeView Vista (basically the VS team put in the extra effort to spice this up on Vista :-)).

Get Orcas Beta 1

Thu, April 19, 2007, 01:30 PM under Orcas | VisualStudio
Visual Studio codename "Orcas" (and NetFx 3.5, C# 3, VB9) has reached Beta 1.

The huge VSTS VPC image is available right now here and other SKUs will follow. You can even get the lightweight Express SKUs here and the TFS Server here. Personally, I'd wait a bit longer for the installable bits of the Pro Edition which for the first time is even supported on Vista :-)

As always the feed that tells you these things is worth subscribing to over here.

Orcas for Web developers

Wed, March 28, 2007, 11:25 AM under Orcas | VisualStudio
My colleague MikeO looks after the web space here in the UK and he started a list of what is new in Orcas here.

Inspired by his list I searched the blogosphere (yeah that word makes me cringe too...) and found more on the three things that caught my eye:
1. Script intellisense (here)
2. New web form designer (here)
3. Better CSS support (here)

If you are a web dev, stay tuned for more Orcas goodness by following those 4 blogs above...

Of course other generic aspects of Orcas apply equally to the web story such as multi-targetting and LINQ.

PeerToPeer in Orcas

Mon, March 19, 2007, 12:37 AM under dotNET | Orcas
In the "Orcas" framework, another green assembly is the System.Net.dll that contains all the new PeerToPeer classes (spread over 3 namespaces: System.Net, System.Net.PeerToPeer and System.Net.PeerToPeer.Collaboration). I saw a nice demo of this by the dev on the team back at TechReady3. In terms of explaining the library, once again the product team are "getting in there" first, so no point duplicating what they have already written. Check out the first post and stay tuned on the p2p blog for more... I've captured a class diagram of 3 key classes here for my future reference...

GCCollectionMode and GCSettings.LatencyMode in Orcas

Sat, March 17, 2007, 05:00 PM under dotNET | Orcas
Some blogs have reported that there are performance improvements in the Garbage Collector that ships with Orcas. That is slightly inaccurate. What is new is the ability to have finer control over the GC, including the ability to suggest to it that it should not run during the execution of a time critical phase (e.g. code block) of your choice (I know some guys that would love that in the .NET Compact Framework but this is a full framework feature only).

I was going to do a proper write up on the additions (1 method, 1 property and 1 enumeration) but Chris beat me to it and, given that he officially tests the feature, he certainly knows a lot more about it than me so go read about the new GC collection modes here and the new GC latency modes here.

ETW in Orcas framework

Wed, March 14, 2007, 03:53 PM under dotNET | Orcas
If you are not familiar with the new Event Tracing for Windows in Vista then read this article. You'll then no doubt be asking yourself "what about access from managed code?". For the answer, go read this blog post.

New Security stuff in Orcas framework

Wed, March 14, 2007, 03:45 PM under dotNET | Orcas
I was going to point to the new crypto algorithms on Shawn's blog, but actually if security floats your boat, just read his entire Orcas category.

If you prefer exploring these things directly in Visual Studio look at the classes in the System.Security.Cryptography namespace in Core.

Installation of March CTP on Vista

Sat, March 10, 2007, 04:02 PM under Orcas | VisualStudio
The point of this post is: do not install the Orcas March CTP side by side with VS2005 on Windows Vista.

This CTP is not meant to be installed directly on Windows Vista. It can happily be used in a VPC on Vista and it is also meant to be installed directly on XPSP2 or WS2K3. Given that Virtual PC 2007 is now free and is supported on Vista, just install it in there or grab the VPC image already built for you. You'll love it. Obviously the final version of Orcas will be supported directly on Vista and indeed so is the plan for the next Orcas drop whenever that comes. Furthermore, the final version of Orcas will side-by-side with VS2005 and while this March CTP does side-by-side, it does have some issues so, again, I would not recommend the side by side thing yet.

Now, given what I just said, you won't be wrong to call me a "fool" for actually installing Orcas on my Vista machine to side by side with my VS2005 installation. This has caused me at least 3 issues:
1. Getting NETCF installed needed some manual help from me, my device forms do not render in the designer and I also had some WM5 SDK conflict issues. If you are not doing device development, these won't affect you of course.
2. My existing installation of Visual Studio 2005 Tools for Office Second Edition broke by the Orcas install e.g. my VS2005 excel add-in projects fail with weird compile errors. I fixed this by repairing the VSTO 2005 SE installation.
3. My Orcas properties grid is broken.
4. I haven't had this issue but others have: "Orcas" Web applications fail on Vista.

On the flip side, all my LINQ demos work great!

Once again, best option is to use the VPC image in our free VPC2007 software. Equally good option is that you install it yourself on a non-Vista machine without VS2005. Remember, it *is* a Community Technology Preview!

equals versus ==

Thu, March 8, 2007, 03:09 AM under Orcas | LINQ
At a recent event where I was presenting on LINQ, I showed a query with a join, similar to the following:
      var results =
from p in Process.GetProcesses()
join p2 in MyProccess.GetMyProcList()
on p.ProcessName equals p2.MyProcName
where p.Threads.Count > 14
orderby p.ProcessName descending
select new { p2.MyProcDescription, ThreadCount = p.Threads.Count, p.Id };
After the session one of the delegates asked me: "Why do we have to use the equals keyword and not just ==". In other words he would have preferred to type:
on p.ProcessName == p2.MyProcName
I didn't have a good answer but promised to look into it.

Looking into it involved pinging the product team and Matt Warren (C# software architect) came up with the reply, which I include unedited, warts and all :-)
"The reason C# has the word ‘equals’ instead of the ‘==’ operator was to make it clear that the ‘on’ clause needs you to supply two separate expressions that are compared for equality not a single predicate expression. The from-join pattern maps to the Enumerable.Join() standard query operator that specifies two separate delegates that are used to compute values that can then be compared. It needs them as separate delegates in order to build a lookup table with one and probe into the lookup table with the other. A full query processor like SQL is free to examine a single predicate expression and choose how it is going to process it. Yet, to make LINQ operate similar to SQL would require that the join condition be always specified as an expression tree, a significant overhead for the simple in-memory object case."
Makes sense!

UPDATE: Vladimir Sadov from the Visual Basic team told me that VB also uses Equals for pretty much the same reasons.

NetFx support in VS Orcas

Tue, March 6, 2007, 04:55 AM under Orcas | VisualStudio
UPDATE: After Beta 1 I updated the screenshot below (you can still view the old one here).

As you know, Orcas is the codename for both the next version of Visual Studio and the next version of the .net framework (v3.5). The great news is, that VS "Orcas" not only lets you create projects that target v3.5 but it can also target v3.0 and v2.0 as the following screenshot shows:


If you pick the wrong template (which I am guessing many will since the version dropdown is in a non-obvious place IMO), then you can change the platform later via the project properties under the Application tab:

In VB, the option to change it later is via the Advanced Compile Options under the Compile tab.


Some will say "at last", all I can say is... "Cool!"

Embedding manifests in Orcas

Tue, March 6, 2007, 04:45 AM under Orcas | VisualStudio | UAC
The first thing you should do with your applications on Windows Vista (and indeed a logo certification requirement) is embed a manifest in your application that effectively tells Windows that your app is aware of User Account Control. I have explained how to do this with VS2005 here. Also Catherine listed a few ways here. Bottom line: create a manifest like this, and embed it in your project with a post-build command: "$(DevEnvDir)..\..\Common7\Tools\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" –outputresource:"$(TargetDir)$(TargetFileName)";#1

In VS Orcas C# projects, life becomes slightly easier. Effectively, there is a combobox under the Application tab in the project properties that allows you to point to a manifest and then it will embed it in the application. I cannot find this option in VB projects yet.

To me, there isn't much difference between pasting the command line from further above in the post build box and instead choosing a combobox item. However the latter does have the advantage of being more discoverable :-)

UPDATE: FYI, I got the below from Saurabh Jain (a dev on the team responsible) with regards to the March CTP:
"There is more support for manifests then you might see.

Firstly, the compilers have new switches for manifest, so there is no post build event.

C:\>csc.exe /? | findstr -i man
/win32manifest:<file>   Specify a Win32 manifest file (.xml)
/nowin32manifest        Do not include the default Win32 manifest
Secondly, if you have a .manifest file in your project, that file will appear in the dropdown. You can then select the file, and it will be passed to compiler. This is how one can add a custom manifest file."

Microsoft.VisualStudio.Shell.WindowPane.OnCreate

Tue, March 6, 2007, 04:21 AM under Orcas | VisualStudio
"An error occurred trying to load the page." is what I encounter in my "Orcas" installation whenever I try to open the project properties grid/designer as captured in the following image:


In case you are facing this too, it is a side by side issue with VS2005. If you've only installed Orcas on your box without VS2005 (or downloaded the VPC image) then you will not have this issue. Sorry, no workaround for now, but fixed for future builds.

This blog entry also explains why some screenshots of the property pages that I am about to post are from my VPC WS2K3 Orcas installation rather than my Vista installation like my other screenshots :)

Automatic properties in C#3

Mon, March 5, 2007, 04:36 AM under Orcas | VisualStudio
I was looking at Ander's slides from Tech Ed Europe and he had one about automatic properties but watching the video he did not cover that in his session. It is the simplest concept imaginable and hence it deserves a simple short blog entry.

In C#3, you can write code like this:
        public string Name
{
get;
set;
}
The compiler generates code like this:
        private string XX;
public string Name
{
get { return XX; }
set { XX = value; }
}
, where XX is not directly accessible to you in code of course. This only works for properties with both getter and setters.

Get the March CTP to try it out yourself.

Administrator in VS Orcas title bar

Mon, March 5, 2007, 04:11 AM under Orcas | VisualStudio | UAC
Anyone running on Vista knows about the new security feature of UAC. A known trick is to right click on a command window shortcut and select "Run As Administrator" to get an elevated command window.


Following that, anything you launch from the elevated cmd will also be elevated. Of course this can be dangerous so when a command window is elevated, it is prefixed with the word "Administrator" (so you can distinguish it from non-elevated command windows).


No other window on Vista will tell you in its caption that it is running as administrator. The reason for that is that you will not typically run an interactive process elevated for a long period of time plus most apps cannot do the accidental damage that an elevated cmd window can. Of course each application developer can decide for their own app what they want to do.

The VS Orcas team decided that they wanted to differentiate an elevated VS instance from a non-elevated instance. They do this by appending a "(Administrator)" string on the title as the following screenshot shows:


I like this, although I would have also liked some consistency between cmd and VS and in fact maybe some official Windows guideline that all apps follow.

Ctrl+Tab in VS Orcas

Sun, March 4, 2007, 09:46 AM under Orcas | VisualStudio
UPDATE: After Beta 1 I updated the screenshot below (you can still view the old one here).

A cute feature introduced in Visual Studio 2005 was that Ctrl+Tab didn't just cycle through the open windows but it also brought up a dialog that let you see what the next window would be (much like Alt+Tab does on Windows XP).

VS "Orcas" builds on that feature by offering a sneak image preview of the next window (much like Alt+Tab does on Windows Vista). Try Ctrl+Tab in your Orcas installation and you should get a window like the following:

Like I always say, the devil is in the details :-)

System.AddIn

Fri, March 2, 2007, 03:47 PM under dotNET | Orcas
Anybody that has built an application that supports AddIns (aka add-in, plug-in, etc) knows that there are many design decisions to make and quite a few subtleties in implementing those decisions in particular when it comes to discovering addins, version resiliency, isolation from the host etc.

In NetFx 3.5 (part of "Orcas"), a whole bunch of classes do all this work on your behalf and all you have to do is make simple method calls to configure the behaviour. These new types are in the following namespaces: System.AddIn, System.AddIn.Hosting, System.AddIn.Pipeline and System.AddIn.Contract.

The implementation was part of System.Core.dll in early CTPs; starting with the March CTP they reside in their own assembly: System.AddIn.dll (be sure to reference the System.AddIn.dll from v3.5 residing in "C:\Windows\Microsoft.NET\Framework\v3.5.20209", not the one from v2.0 that appears in the References dialog by default).

To learn more about how to use the new AddIn model, please read the two part msdn magazine article (part one and two). Also check out the AddIn blog where you can learn about internal implementation decisions that could help you with the add-in infrastructures that you build today! For a real example of the AddIn classes, see this blog series that describes how Paint.NET is being refactored to take advantage of the new plumbing.

Code metrics in VS "Orcas"

Thu, March 1, 2007, 03:28 PM under Orcas | VisualStudio
One of the new menus I noticed when right clicking on the project menu was one titled "Generate Code Metrics".

I played with it and just before writing a long blog entry, I found that the feature team have done that already so to avoid duplication please go read all about it on the fxcop blog (plenty of screenshots there). The title of the menu gives away what it does but to whet your appetite, if you try to add/remove columns from the code metrics window you get the following dialog:

Now all we need is to make that dialog resizable :)

Some .NET Framework 3.5 features

Thu, March 1, 2007, 02:02 PM under dotNET | Orcas
Thom has a table of .NET Framework 3.5 features and Matt talks about new WCF and WF bits in 3.5 - both well worth a read!

VS "Orcas" uses the new CommonFileDialog

Thu, March 1, 2007, 05:21 AM under Windows | Vista | Orcas | VisualStudio
Whenever I see an application on Vista that shows the old file dialog, I cringe (sorry, it is true). So given that I "live" in VS2005, it is the one that irritates me the most every day in that respect. It is easy to show it from native code and I have talked about the managed wrapper in VistaBridge before.

I've been waiting for a VS "Orcas" build that uses the new CommonOpenFileDialog when running on Vista and the March CTP does just that. All I can say is "WOO HOO".

Download the Orcas March CTP now

Wed, February 28, 2007, 04:25 AM under Orcas | VisualStudio
Finally, I can empty my queue of Orcas draft blog posts :-)
Get the installable bits here and the VPC image here.

1st March: Updated with screenshot.

LINQ Resources

Tue, February 20, 2007, 04:37 AM under dotNET | Orcas | LINQ
In order to really understand LINQ and before moving to LINQ to data/xml/etc, one has to appreciate the features that LINQ builds on and how LINQ to objects works (unless you like to think of it as magic :)).

To that end I suggest you read my blog entries in order:
1. LINQ
2. Local Variable Type Inference (and the VB version)
3. Object Initiliasers
4. Anonymous Types
5. Extension Methods
6. Lambda Expressions (and the VB version)
7. Decomposing LINQ (includes Query Expressions)

My 1 hour talk on LINQ is coming to a city near you (if you live in the UK) and my code-littered slides are available to download here (pptx format).

If you want to play with LINQ you need Orcas. You can get the May CTP of last year or the January CTP from this year but to be brutally honest, namespaces/syntax/features have changed so the one you really really want is the Feb/March CTP so I would wait for that one which is just round the corner.

For even more info, see the following links:
- Official LINQ page
- We have some screencasts here and channel9 has some media here.
- Plenty of blogs with LINQ or C#3 or VB9 categories and some of them are here, here, here, here, here and here.
- For more, search.

For all your questions, as usual the msdn forums offer free support so please go there.

Decomposing LINQ

Sun, February 18, 2007, 07:04 PM under dotNET | Orcas | LINQ
Please revisit the example from my previous post on LINQ. Here I only include the query snippet of code:
       var results =
from p in Process.GetProcesses()
where p.Threads.Count > 6
select new {p.ProcessName, ThreadCount = p.Threads.Count, p.Id };
...or in VB if you prefer:
    Dim results = _
From p In Process.GetProcesses() _
Where p.Threads.Count > 6 _
Select New With {p.ProcessName, .ThreadCount = p.Threads.Count, p.Id}
The above is based on a number of new language features including one that I have not mentioned until now: query expressions. If we were to take away query expressions, the code above would look like this:
   var results =
Process.GetProcesses()
.Where(p => p.Threads.Count > 6)
.Select(p=>new {p.ProcessName, ThreadCount = p.Threads.Count, p.Id });
In VB:
    Dim results = _
Process.GetProcesses() _
.Where(Function(p) p.Threads.Count > 6) _
.Select(Function(p) New With {p.ProcessName, .ThreadCount = p.Threads.Count, p.Id})
The two snippets above are identical. There isn't much more to explain about Query Expressions other than... that is the way it is! The two code snippets above are identical, the first one using query expression syntax to beautify the real code shown in the 2nd one.

So let's look at the 2nd snippet more closely. The first line (Process.GetProcesses()) returns an array and we know that arrays implement IEnumerable. Well it turns out that in Framework 3.5 there are some extension methods for IEnumerable including a method called Where that takes as an argument a delegate (named Func) and returns an IEnumerable. This extension method (along with other extension methods) and the delegate it accepts (along with other delegates) are in the System.Linq.Enumerable class that is in Core dll.

Given what we just said, the second line above (.Where(p => p.Threads.Count > 6)) should make a lot more sense now: the way we pass in a delegate to the Where extension method is by using a lambda expression (VB lambda link). The 3rd line of code is also straightforward once you know that another extension method on IEnumerable is Select. It also takes a delegate and we used a lambda expression for that as well. Note how in the body of the lambda we use anonymous types. What Select returns is a generic IEnumerable of the anonymous type we create on the fly. Since we cannot write compilable code of an IEnumerable of an anonymous type, we use local variable type inference (VB inference link) for the results variable and again take advantage of inference when we want to access each element:
      foreach (var o in results)
{
Console.WriteLine(o.ToString());
}
Note that if you look closely at the extension methods in Enumerable and the delegates in the System.Linq namespace, you will find extreme usage of generics and that is how that code can deal with arbitrary conditions, anonymous types etc that are used in LINQ queries. Don’t forget the compiler magic of course that does generate quite a bit of goo in addition to the code you write. For that last point, compile the code above and open the assembly with reflector and you'll see what I mean :-)

To finish off, take a glance at the original query without the query expression syntax; what would the code look like if we also took away all the new language features (but still using the new Enumerable class of the Framework 3.5)? First we have to write two extra methods and declare a helper class):
    private class MothAnonymousType
{
public string ProcessName;
public int ThreadCount;
public int Id;
//
public override string ToString()
{
return "{ ProcessName = " + ProcessName + ", ThreadCount = " + ThreadCount + ", Id = " + Id + " }";
}
}
private static bool MothWhere(Process p)
{
return p.Threads.Count > 6;
}
private static MothAnonymousType MothSelect(Process p)
{
MothAnonymousType type1 = new MothAnonymousType();
type1.ProcessName = p.ProcessName;
type1.ThreadCount = p.Threads.Count;
type1.Id = p.Id;
return type1;
}
and then our calling code changes to this:
    static void Main(string[] args)
{
IEnumerable<MothAnonymousType> results =
Enumerable.Select(
Enumerable.Where(Process.GetProcesses(), new Func<Process, bool>(MothWhere)),
new Func<Process, MothAnonymousType>(MothSelect));
//
foreach (MothAnonymousType o in results)
{
Console.WriteLine(o.ToString());
}

Console.ReadLine();
}


I think I prefer the original query syntax don’t you ;-)

Lambda Expressions in VB9

Sun, February 18, 2007, 06:54 PM under dotNET | Orcas | LINQ
This short blog entry assumes that you have read my description of C# lambda expressions and here I will literally just show you the proposed VB syntax that corresponds to the lambda we ended up with in that blog post: i => i > 2. The corresponding syntax is: Function(x) i > 2

So, the full example, given the following code:
  Delegate Function SomeDelegate(ByVal i As Integer) As Boolean
Public Sub SomeMethod()
'
'REMEMBER FROM LAST TIME, THE KEY LINE IS THE FOLLOWING
Dim sd As SomeDelegate = New SomeDelegate(AddressOf OtherMethod)
'
' other code here
YetOneMore(sd)
End Sub
Private Function OtherMethod(ByVal i As Integer) As Boolean
Return i > 2
End Function
Private Sub YetOneMore(ByVal f As SomeDelegate)
Dim res As Boolean = f(5)
Console.WriteLine(res.ToString())
End Sub
We can get rid of the OtherMethod method completely and inline on the delegate creation line using the VB9 lambda expression sysntax, like this:
    Dim sd As SomeDelegate = Function(i) i > 2

WARNING: for this feature only and for the VB case only, I do not have a compiler that supports it yet. Unlike all my other blog posts, I am basing the above on a spec rather than hands on experience. If I find that it changes when I get new bits, I will come back here and update this.

Lambda Expressions C# 3.0

Sun, February 18, 2007, 06:48 PM under dotNET | Orcas | LINQ
There are two aspects to lambda expressions and I will only discuss one of them in this post. The aspect not discussed is the one that is most useful, but to get there we must first understand the syntax, which follows.

Lambdas are simply shorthand to creating a delegate and pointing it to a method plus they offer type inference. Consider the following C# example:
delegate bool SomeDelegate(int i);
public void SomeMethod()
{
SomeDelegate sd = new SomeDelegate(OtherMethod);
//
// other code here
YetOneMore(sd);
}
private bool OtherMethod(int i)
{
return i > 2;
}
private void YetOneMore(SomeDelegate f)
{
bool res = f(5);
Console.WriteLine(res.ToString());
}
Nothing complicated (or useful) takes place. Before I rewrite it using a lambda expression, let's re-write it a bit using C# 2.0 anonymous methods:
delegate bool SomeDelegate(int i);
private void SomeMethod()
{
SomeDelegate sd =
delegate(int i){return i > 2;}
;
//
// other code here
YetOneMore(sd);
}
private void YetOneMore(SomeDelegate f)
{
bool res = f(5);
Console.WriteLine(b.ToString());
}
If you are not familiar with anonymous methods, basically we have inlined OtherMethod by using the delegate keyword.

Lambda expressions take this to the next level of conciseness.
This line:
    delegate(int i){return i > 2;}
can be written like this:
    (int i) => { return i > 2;}
so all we've done there is replace the delegate keyword with the funny syntax =>

However the beauty is that given the body only has a single return statement, we can make it even more concise *and* get the compiler to infer the parameter type:
 SomeDelegate sd = i => i > 2;
And that is the basics of lambdas: it looks weird, it is concise and it does some inference for us. In the future I will post about the other aspect of lambdas which is actually what most people are excited about: lambdas bound to parameter expressions.

Extension methods C# 3.0 and VB9

Sun, February 18, 2007, 06:43 PM under dotNET | Orcas | LINQ
How many times have you written wrapper methods for objects that in reality you wished were part of the object itself? For example, if you find yourself checking in multiple places if a string is all uppercase, you may write a wrapper method for it, e.g.:
namespace Helper
{
public static class StringHelper
{
public static bool IsAllUpper(string s)
{
//implementation left as an exercise to the reader
}
}
}
...or in VB if you prefer:
Namespace Helper
Public Module StringHelper
Public Function IsAllUpper(ByVal s As String) As Boolean
'implementation left as an exercise to the reader
End Function
End Module
End Namespace
...which you then call like this (assuming the Helper namespace is in scope):
string s = ...
bool itIs = StringHelper.IsAllUpper(s);
In VB:
Dim s As String = ...
Dim itIs As Boolean = StringHelper.IsAllUpper(s)
...when really, what you want is something more readable like this:
bool itIs = s.IsAllUpper();
In VB:
Dim itIs As Boolean = s.IsAllUpper()
That is exactly what extension methods let you do. To achieve that, a new attribute has been introduced: System.Runtime.CompilerServices.ExtensionAttribute (in System.Core.dll).

In the VB example above, simply add the Extension attribute to the method in the module:
    <Extension()> _
Public Function IsAllUpper(ByVal s As String) As Boolean
...
In c#, there is a shortcut to using the attribute which makes the following two represent the same thing:
[Extension()]
public static bool IsAllUppercase(string s) {...}

public static bool IsAllUppercase(this string s) {...}
...except the C# compiler will not let you write the first version and will instruct you to use the "this" keyword instead (a bit like it doesn't let you write an explicit finalizer method and instead instructs you to use destructor syntax).

So, back to our example, if in the c# case we simply insert the this keyword before the string argument in the IsAllUpper helper method (and in the VB case insert the Extension attribute before the method) then we can indeed type s.IsAllUpper() and the compiler is happy. In fact, the advantage of doing this is that intellisense will help you by showing the method when you type a dot after the variable thus making the helper method much more discoverable than what it would be today - see the following screenshot for how it distinguishes extension methods from normal methods by sticking an arrow in front:


Please note the following points which hopefully help answer any questions you might have:
0. It is not by accident that I chose a static class in C# and a module in VB. Those are the only places where you can define extension methods.
1. The compiler generates the longhand version: no magic is taking place here at runtime. Since you are not *really* adding a method to the class, you can only access public members of the object (e.g. only public members of the string in our example) from your extension method. It also follows that extensions are available to subclasses of the class you are extending.
2. For an extension method to be visible/applicable/in scope, you must import the namespace it resides in. So in our example, if you do not stick a using Helper; (or in VB Imports Helper) at the top of the file where you make the call, the extension method would not show up in intellisense and would not compile.
3. If two namespaces with extensions methods that have the same name are brought into scope, a compile error occurs; hence the usefulness of the previous point.
4. If you add to the object a real method that has the same name as the extension method, the real method takes precedence and your extension method is silently ignored.
5. Extension methods for properties are not possible.

Overall, I like this feature *a lot* (will post some concrete examples of why in the future). My only worry is that some devs will get lazy and use extension methods rather than inheritance when the latter is more applicable... time will tell.

Anonymous Types in C# 3.0 and VB9

Sun, February 18, 2007, 06:38 PM under dotNET | Orcas | LINQ
Recall local variable type inference (and the VB9 story) and object initialisers? Here is a reminder:
var o = new SomeType(); //inference
SomeType o = new SomeType {SomeField=DateTime.Now, AnotherField=5.6}; //initialisers
We can of course combine them:
var o = new SomeType {SomeField=DateTime.Now, AnotherField=5.6};
...or in VB if you prefer:
Dim o = New SomeType With {.SomeField = DateTime.Now, .AnotherField = 5.6}
Now, imagine that you were only using variable o in a single method. Also imagine that the type of o (SomeType) only has public fields/properties and no other methods/functions. Also imagine that SomeType was not used anywhere outside that single method. I know all this requires vivid imagination but humour me and picture that scenario.

Well, in the imaginary scenario, you really don't need to declare/define the type! Think about it, why would you need to know what type o is? All you need to be able to do is create something that looks like it and access the public fields/properties. That is exactly what the “anonymous types” feature offers:
var o = new {SomeField=DateTime.Now, AnotherField=5.6};
In VB:
Dim o = New With {.SomeField = DateTime.Now, .AnotherField = 5.6}
In the code above, the compiler generates a class for us, which is visible in IL. The name of the type is not visible to our code and the name is not otherwise usable. Hence we call the feature: anonymous types. If you use your favourite disassembler you can see what the name of the type is but that information will be of academic value.

Another featurette of anonymous types is that the compiler can infer the field names so if you amend the code above like this:
var o2 = new {DateTime.Now, AnotherField=5.6};
In VB:
Dim o2 = New With {DateTime.Now, .AnotherField = 5.6}
...then the anonymous type will have a property called Now that has the value of DateTime.Now and this will of course show up in intellisense e.g. Console.WriteLine(o.Now);

Also note that anonymous types override the ToString method and return something sensible in the format “{Field1 = value1, Field2 = value2}”

Of the three new language features that I've described so far, anonymous types looks like the most useless. Stick with this one for a while. When I bring it all together for LINQ, you'll see the usefulness of the feature.

Object Initializers in C# 3.0 and VB9

Sun, February 18, 2007, 06:36 PM under dotNET | Orcas | LINQ
How many times have you created an object and immediately started setting properties on it? For example, wherever I create a Thread object I use the following almost boilerplate snippet:
Thread myThread = new Thread(MyThreadMethod);
myThread.Name = "my thread";
myThread.IsBackground = true;
..or in VB if you prefer
    Dim myThread As New Thread(AddressOf MyThreadMethod)
myThread.Name = "my thread"
myThread.IsBackground = True
With object initialisers, you can combine the first 3 statements into one like so:
Thread myThread = new Thread(MyThreadMethod) {Name="my thread", IsBackground=true};
In VB:
Dim myThread As New Thread(AddressOf MyThreadMethod) With {.Name = "my thread", .IsBackground = True}
So, object initialisers is a feature that lets you assign public properties (and public fields) straight after the constructor in braces, without having to repeat the object variable name and type separate statements.

Note that the compiler generates the long hand code. For example, when you type the following statement:
TextBox t = new TextBox {Text="Hi", Multiline=true, Location = new Point(5,5), Size=new Size(50,100)};
In VB:
Dim t As New TextBox With {.Text = "Hi", .Multiline = True, .Location = New Point(5, 5), .Size = New Size(50, 100)}
...the compiler generates IL similar to if you typed:
      TextBox t = new TextBox(); 
t.Text = "Hi";
t.Multiline = true;
t.Location = new Point(5, 5);
t.Size = new Size(50, 100);
This feature saves you some typing and results in more concise code. While I like object initialisers, their full usefulness will become apparent when combined with the language enhancement that we look at next.

Option Infer in VB9

Sun, February 18, 2007, 06:30 PM under dotNET | Orcas | LINQ
I will assume here that you have read the narrative to my C# post about local variable type inference and build on it to discuss the VB syntax.

The VB syntax for local variable type inference is:
Dim i = 3
Dim s = "hi"
Dim o = New SomeType()
...which the compiler generates as:
Dim i As Integer = 3
Dim s As String = "hi"
Dim o As New SomeType()
Note that for reference types, you are not really saving a lot of typing compared to C#. The example I used in that post was:
    Dim myCol = New Dictionary(Of Integer, SomeType)()
, which represents a saving of only one character in VB:
    Dim myCol As New Dictionary(Of Integer, SomeType)()
What is more important is that some VB developers will be thinking right now “So what? I could always type Dim o = whatever”. My answer is “Not if you turned Option Strict On”. Don’t forget what I wrote in the c# version: this is early binding. Like shown above, the compiler infers the type and generates it for you. At this point, the astute reader will have a question: “So if I turn off Option Strict, then what happens? The old behaviour or the new?”. To which my answer is “Excellent point, let’s talk about that :-)”.

There is a new option in VB9: Option Infer. Option Infer, like its cousins, can be turned on/off at the project level or at the code file level. If you have Option Strict Off, then whether a variable has the old behaviour or new is determined by the setting of Option Infer. This also means that, unlike c#, you can turn off local variable type inference even in the strongly typed world (by setting Option Strict to On and then Option Infer to off). I believe the default for new VB projects will be that Option Infer is On.

There is a good opportunity here for all that VB6 code you ported over to .NET land and did not want to revisit with Option Strict On. If you turn Option Infer On, the code that did work, will now work faster. The code that had issues, will still have issues (for that you must still turn option Strict On).

Anyway, back to our syntax, the following example shows how to get variable inference in the For Each case like I showed before in C#:
    Dim col As IEnumerable(Of SomeType) = New SomeCollectionType()
For Each a In col 'a is inferred by the compiler to be SomeType
a.MethodOnSomeType() 'intellisense here pops-up as expected
Next
In the code above, the variable a is inferred by the compiler to be SomeType. Of course, if you turn Option Infer Off, then you will get a compiler error even with Option Strict Off. The only way not to get a compiler error for variable a is to turn Option Explicit Off too but we know that is just mad.

More language features follow!

Local variable type inference in C# 3.0

Sun, February 18, 2007, 06:22 PM under dotNET | Orcas | LINQ
A new feature in C# version 3 that comes with Orcas allows you to declare variables within the body of a method like this:
var i = 3;
var s = "hi";
var o = new SomeType();
Note that the compiler generates IL that is identical to what it would generate if you typed:
int i = 3;
string s = "hi";
SomeType o = new SomeType();
In other words the 2nd line below compiles fine but the 3rd does not compile:
var b = true;
b = false; //fine
b = "pull the other one"; //Cannot implicitly convert type 'string' to 'bool'
So, the important point is that this local variable type inference, results in early-bound strongly-typed code. There is no late-binding taking place, besides the similarity with the var keyword in script languages where everything is an object/variant - that is not the case here.

Another point to stress is that variable inference does not work for class level fields or method arguments or anywhere else other than for local variables in a method.

Another example is the following:
IEnumerable<SomeType> col = new SomeCollectionType();
foreach (var a in col) //a is inferred by the compiler to be SomeType
{
a.MethodOnSomeType(); //intellisense here pops-up as expected
}
It is neat that the compiler can infer what type you expect a variable to be by looking at the right hand-side of the assignment, but I personally will not be using this often as I prefer explicitness. I guess it is a time saver for very long types, for example:
// I'd rather type this
var myCol = new Dictionary<int, SomeType>();
//...than type this
Dictionary<int, SomeType> myCol = new Dictionary<int, SomeType>();
Local variable type inference is a feature that seems not very useful in its own right, but becomes important when used in conjunction with other language enhancements.

Language INtegrated Query

Sun, February 18, 2007, 06:16 PM under dotNET | Orcas | LINQ
The biggest announcement at the last PDC was the LINQ project. It is now the headline feature of Orcas offered to all developers from web to client to device. Given that there are no changes to the runtime engine in Orcas, you will not be surprised to learn that LINQ is based entirely on compiler magic, the introduction of some fancy new syntax and some help from Core.dll.

LINQ simplifies querying objects, data and XML by integrating query and transform operations into the programming language (currently VB9 and C#3). It introduces a concise declarative syntax that is consistent irrespective of what your underlying data source is: in memory custom objects, datasets, XML, Entities etc. LINQ is also highly extensible which means that we are already seeing LINQ to other sources (e.g. search for blinq, plinq, linq to amazon, linq to WMI and so on).

I think that most devs will make most use of the LINQ-enabled ADO.NET (LINQ to SQL, LINQ to DataSet and LINQ to Entities) and of LINQ over XML. Before you start learning about those, it is my opinion you should learn about LINQ to objects first and then build on that.

Here is an example of some LINQ syntax:
    static void Main(string[] args)
{
var results =
from p in Process.GetProcesses()
select p;
//
foreach (var o in results)
{
Console.WriteLine(o.ToString());
}
//
Console.ReadLine();
}
This will output in your console a list of all the running processes on your machine in the following format "System.Diagnostics.Process (devenv)".

We can modify the query as follows:
        from p in Process.GetProcesses()
where p.Threads.Count > 6
select p;
...which unsurprisingly will trim the list to only show processes that have more than 6 threads.

We can modify the query further like so:
        from p in Process.GetProcesses()
where p.Threads.Count > 6
orderby p.ProcessName descending
select p;
...which due to the easily readable nature of linq, you can easily tell that it orders the resulting list of processes in descending order by the ProcessName (on my machine that puts the winlogon process at the top).

How about if I just want to see a few specific properties of each process (say Name, thread count and process id) ? Easily done by changing the query as follows:
        from p in Process.GetProcesses()
where p.Threads.Count > 6
orderby p.ProcessName descending
select new {p.ProcessName, ThreadCount = p.Threads.Count, p.Id };
...which on my machine produces this screenshot.

Finally, the Visual Basic syntax for the example above follows:
  Sub Main()
Dim results = _
From p In Process.GetProcesses() _
Where p.Threads.Count > 6 _
Order By p.ProcessName Descending _
Select New With {p.ProcessName, .ThreadCount = p.Threads.Count, p.Id}
'
For Each o In results
Console.WriteLine(o.ToString())
Next
'
Console.ReadLine()
End Sub
I think you get the idea: Picture the code you would have to write today to achieve the same results! The code above is easier to write, easier to read and maintain, and much more concise. Furthermore, because of its declarative nature, the compiler can perform any optimisations that it sees fit and is not restricted to your imperative solution (this is a promising aspect and one I'll revisit in the future). The other benefit is that the syntax you see above can be used to query XML and data as hinted at the beginning of this post. Again, you’ll hear more on that in a future blog entry.

The next step is to understand how the above funny syntax really works and that is the subject of my following blog entries available right now :)

Threading.ReaderWriterLockSlim

Wed, February 7, 2007, 04:16 PM under dotNET | Orcas
System.Threading is yet another namespace in System.Core.dll. There is only one main class in there: ReaderWriterLockSlim (don’t worry, System.Threading.ReaderWriterLock is still there in the mscorlib dll). The other types in the namespace are there just in a support role, including the LockRecursionPolicy enumeration and the LockRecursionException class. Joe has the details on ReaderWriteLockSlim here.

System.IO.Pipes

Wed, February 7, 2007, 03:39 PM under dotNET | Orcas
With a whole bunch of types, one of the biggest new namespaces in System.Core.dll is System.IO.Pipes (and support for it is required by types in other new namespaces in System.Core). Collectively the classes in there wrap their native counterparts to offer inter-process communication. You could achieve some IPC over named pipes in .NET remoting as I mentioned ages ago here. This new namespace in Orcas takes it to the next level and beyond and Justin has the full story here.

System.TimeZone2

Wed, February 7, 2007, 03:36 PM under dotNET | Orcas
Another namespace in System.Core.dll is System. It contains two exception classes (InvalidTimeZoneException and TimeZoneNotFoundException) and the TimeZone2 class (that further contains two types: AdjustmentRule and TransitionTime). Kathy has the details on TimeZone2 here.

System.Numeric.BigInteger

Wed, February 7, 2007, 03:33 PM under dotNET | Orcas
A new namespace in System.Core.dll is System.Numeric. There is a single type contained within, the BigInteger structure. Inbar has the details on BigInteger here.

System.Collections.Generic.HashSet

Wed, February 7, 2007, 03:31 PM under dotNET | Orcas
One of the namespaces in System.Core.dll is System.Collections.Generic with a single class HashSet (and its Enumerator of course). Kim has the details on HashSet here.

System.Core.dll

Wed, February 7, 2007, 02:45 PM under dotNET | Orcas
If you are looking for new stuff in the .NET Framework v3.5, you need to look at the new assembly System.Core.dll. NOTE: In the January CTP of Orcas you have to browse the file system in order to add a reference to it (i.e. navigate to C:\Windows\Microsoft.NET\Framework\v3.5.11209\). In future CTPs, it will be added by default to NetFx3.5 projects.

There are a whole bunch of namespaces in System.Core.dll from System and System.Diagnostics to System.IO and System.Security etc (but none named System.Core). Quite frankly, I’d prefer to see the namespaces/types move to where their friends are in mscorlib.dll, system.dll etc. I strongly doubt this will happen in the short term though given the desire to leave existing assemblies with no modifications.

In other words, System.Core.dll is your main “green” assembly, while the older ones are “red”. For more on the green and red bits in Orcas read these blog entries here and here.

Open Folder in Windows Explorer in Orcas

Wed, February 7, 2007, 04:33 AM under Orcas | VisualStudio
I discovered a small new feature in the Visual Studio “Orcas” IDE which I am already finding useful.

How many times have you had a Visual Studio solution open and you wanted to quickly open Windows Explorer and navigate to the folder of the solution or maybe the folder of the project or maybe the build folder (e.g. Bin\Debug)?

What I used to do with VS2005 is open a code file, right click on its tab and select “Open Containing Folder” (don’t tell me you didn’t know about that one!) and then navigate up/down to go where I really wanted to be. In particular, many times I would “Show All Files” in Solution Explorer, then expand the bin\Debug folder, open the pdb file in VS just so I could right click on its tab and select “Open Containing Folder” (sounds long winded but is actually much faster than any alternative):


Now with Orcas, life becomes easier. Simply go to Solution Explorer select the solution node or the project node (or even a bin/obj folder if you have shown all files) and then... right click:

Notice just above “Properties” the new menu item “Open Folder in Windows Explorer”? It does exactly what you expect it to (and yes, I know that I am easily pleased :-D)

BTW, if you want to assign a shortcut key to the command (via Tools->Options->Environment->Keyboard), its name is ProjectandSolutionContextMenus.Project.OpenFolderInWindowsExplorer.

"Orcas"

Wed, January 31, 2007, 03:35 PM under dotNET | Orcas | VisualStudio
This blog will get an additional focus over the coming months: "Orcas" :-)

Before Visual Studio 2005, .NET Framework v2.0, C#2, VB8 and CLR v2.0 shipped, they collectively had the code name "Whidbey".

As we know, recently the .NET Framework v3.0 shipped, which leaves intact the languages, CLR and existing Framework bits. It also continues to take advantage of the same VS2005 albeit with WF extensions (and no released tool bits for WPF & WCF).

Next, we are going to see an update to the Framework bits (v3.5), languages (C#3, VB9) and Visual Studio; collectively the update has the codename "Orcas". I will label/tag such topics as 'Orcas'. The "Orcas" release also includes a new version of the .NET Compact Framework (v3.5) along with new integrated Visual Studio for Devices enhancements. I will continue to tag/label those topics as 'Mobile and Embedded'.

Until now I’ve refrained from diving into "Orcas" for various reasons. I can tell you that even though the documentation doesn’t list Windows Vista as supported, I finally have the "Orcas" January CTP running fine on Vista both in VPC 2007 and directly installed. Stay tuned :-)

VS “Orcas” September CTP

Sat, September 30, 2006, 03:58 PM under Orcas | VisualStudio
One of the areas I will be focusing on as we move forward is the next version of Visual Studio code-named Orcas. So, when I got word last week (while on the road) that the 1st CTP was out, I couldn’t wait to come back home and play with it.

Unfortunately, it doesn’t look like I will be doing any playing :-( Not because this CTP doesn’t include all the LINQ bits or because it doesn’t include all the C# 3.0 bits or even all the VB9 bits. No, the reason I won’t be playing is because it is released as a VPC image that is not supported on Windows Vista. I just don't have any machines (or partitions) with XP on them (and quite frankly don’t want to ever go back to XP). Shame, as I was looking forward to playing with unit testing on devices and the other improvements for the NETCF developer.

Oh well, looking forward to the next drop and let’s hope there will be support for Vista (or that I decide to use Virtual PC 2007 Beta on Vista RC to test a CTP)!

If you can though, check it out and be one of the first to start blogging about what you like and what not. Download the Orcas September CTP here.