Parallel Extensions

Fri, November 30, 2007, 09:17 AM under dotNET | ParallelComputing
The Parallel Extensions to .NET Framework 3.5 is available! Download and play with the first ever public drop - the December CTP.

If you are then ready to dig into it, I have three 20' screencasts (plus more cooking):
1. Tour of the Samples. A tour of what gets installed to get you started.
2. Declarative data parallelism. This is about PLINQ.
3. Imperative data parallelism. This is about the static Parallel class.

After watching the above, visit the relevant MSDN dev centre. For any questions please use the dedicated online forums. For feedback please use the connect site. If you want to congratulate or blame the product team, visit their blog.

Parallel Extensions videos Errata

Thu, November 29, 2007, 03:01 PM under dotNET
If you watched my videos here, please note the following clarifications:

First, in all videos I am using the old internal sort-of-a codename "PFX". This is no longer used internally or externally. Instead just refer to it as Parallel Extensions.

Second, in the PLINQ video, when I very briefly mention what pipelining does, my description is outdated; for an up to date description of pipelining please see this. Also in the same video I do not make it clear that the ForAll option will *not* allow you to preserve ordering.

Third, in the Parallel video, where I use return sum and imply that it is the same as return 0, I am obviously wrong: The issue is that it’s possible for the first thread to complete so fast that the second thread doesn’t have any work to process. The first thread will store its partial result back into the total sum, but since the thread local selector delegate has captured that total sum variable, the second thread will be initializing its partial sum with the total sum that already includes the first sum’s partial. Thus, you could end up counting values twice so you should use return 0 instead. In the same video, if you really wanted to simulate break, in the parallel version you would have to add a return statement after the ps.Stop() statement that I used.

MSDN Flash 28 Nov

Thu, November 29, 2007, 02:50 PM under Links
The MSDN Flash was delivered yesterday (subscribe here). In the editor's intro you'll find where and when the UK 2008 Launch takes place – you can view this issue online now.

The manycore shift white paper

Thu, November 29, 2007, 01:17 AM under ParallelComputing | Links
"Parallel Computing Initiative Ushers Computing into the Next Era"
A bit high level (marketing?) at times in this 10-page document, but there is definitely some interesting stuff in there - read it!

Futures, promises and dataflow programming

Wed, November 28, 2007, 04:25 PM under ParallelComputing | Links
I am a bit slow so I had to read this page twice on wikipedia, but it was worth it in the end, I think. See if you get it all in one pass: Futures and Promises. Because my imperative head wasn't completely blown away I also spent time trying to grok dataflow programming. Opens your mind doesn't it?

Concurrency and Parallelism

Wed, November 28, 2007, 09:50 AM under ParallelComputing | Links
Via Jason, I discovered this post on the concurrency learning curve and following links from there, I found Intel's view on "data and task parallelism". Interesting stuff!

ThreadPool in .NET Framework v2.0 Service Pack 1

Wed, November 28, 2007, 02:42 AM under dotNET
I was in Joe's session at Tech Ed when he mentioned in passing (almost as a throwaway comment) that there are some changes in the System.Threading.ThreadPool in v3.5. I guessed that what he really meant was changes in v2.0 Service Pack 1 for the ThreadPool class (which I confirmed myself by testing it on my machine). It goes to show you that you cannot rely on API surfacing to discover all the changes in SP1 and somebody should come up with a master list... Anyway, you are probably more interested in what the change is, right?

Apparently, the ThreadPool now defaults to having a max of 250 threads instead of 25. I found this ironic because I recall that the NETCF ThreadPool had 256 in v1.0 and changed to 25 to match the desktop behaviour in v2.0 and I wondered if they caught this change in NETCF v3.5 so they can be in sync again. Seems not :-)

Regardless, remember that starting with v2.0 you can change the max yourself not just through hosting APIs but through the managed SetMaxThreads method. In fact, to validate all of the above, I used the counterpart method, GetMaxThreads that you can try yourself:
  int a, b;
ThreadPool.GetMaxThreads(out a, out b);

Blend with VS2008

Tue, November 27, 2007, 05:14 PM under Links
If you are looking for a copy of Expression Blend that works and is supported with VS 2008, look no further than Blend SP1.

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:

Silverlight for VS2008

Tue, November 27, 2007, 12:52 AM under Links
Silverlight 1.1 Tools Alpha for VS2008 spotted in the wild.

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\\MyWpfExtension.vb

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

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:
<ul class="myCSSrule">
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
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=, 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.

Code Camps in the UK

Sun, November 18, 2007, 06:13 AM under Events
In the US they run these things called Code Camps which essentially are a 1-day community conference. If it rings a bell with my UK friends, it should: That is where we borrowed the whole idea of DDD. Spot the similarities in this very useful checklist for Code Camps.

The main difference with DDD in the UK is that the delegates vote for the sessions beforehand and that no Microsoft employees are welcome to present/speak (this is not true for other code camps in the UK such as WebDD and SQLBits). Is there anyone out there that has attended one of these things on both sides of the pond? Is there anyone out there that does this sort of thing in their own country (not UK or US)? I think there is room for evolution which can be expedited by sharing cross the borders...

Anyway, besides not being allowed to present, I will be around mingling at DDD6 on Saturday 24th (as promised), so I look forward to saying "hello" to many of you in the UK reading this blog... I hope you return me the favour and if you do ask me about ClientDD or ToolsDD :-)

MSDN Flash 14 Nov

Thu, November 15, 2007, 04:25 AM under Links
The MSDN Flash was delivered earlier (subscribe here). There is a FULL roundup of the Tech Ed announcements and downloads. Also, as usual, you can purchase the featured MS Press book (this time it is a Silverlight book) at a huge discount for a limited time (until the next Flash issue comes out) – you can view this issue online now.

My personal Tech Ed wrap-up

Sun, November 11, 2007, 04:55 AM under Random
This year I was presenting 4 breakout sessions on my own and was also part of a panel session with four other speakers. A huge thank you to all of you that attended my sessions and in particular to those of you that filled in the feedback forms. I read every single comment and below are the results of your voting, in the order I presented throughout the week:

Three numbers per session representing speaker's Knowledge, Presentation Skills and Quality (range is 1-9 where 9 is high).

TLA201 VisualStudio – 8.41, 8.31, 7.87 (resources here).
MED202 WindowsMobile – 8.46, 8.32, 7.85 (resources here).
MED304 CompactFramework – 8.49, 8.33, 8.09 (resources here).
WIN312 WindowsVista – 8.66, 8.54, 8.31 (resources here).

These numbers are not that different to my session results from last year so it sounds like I am not improving much. I hope next year I will do better i.e. eliminate those two pesky 7.8x numbers and replace them with 8.something!

In addition to having a session every single day and almost every day some kind of "lunch meeting", I also kept my evenings busy by managing to attend: the welcome drinks reception, the MVP party, the MSP party, the UK country drinks, a night out with MS UK DPE colleagues and the speaker's dinner/party. I also participated in two book signing events at one of which Andy "helpfully" brought a celebratory bottle of champagne. So, in hindsight, maybe I should do all my presentations from now on whilst being hangover since it apparently makes no difference ;).

It wasn't all alcohol and presentations though; there were some "media" activities too. At some point expect to see on channel8 an interview I gave to two MSPs. I also turned the table round with Dave by interviewing him on his outstanding performance at Tech Ed – expect to see that on the NxtGenUG podcast series. There is 30 seconds on us signing the book on the Day 3 Wrap (start at 01:09) on the virtual side (or save as the wmv). Also on the virtual side there is a 4-minute chat between me and Mike on Visual Studio & .NET Framework 3.5 – Top Features (or save as the wmv). Finally, since they had both me and Mike in front of a camera, they decided to record a longer (10') chat we had on the same topic, this time for VisrtualTechEd (stream it or save as the wmv).

Phew! Now I think I'll get some rest and sleep for the next 24 hours and then compile for the Flash all the announcements and product downloads from Tech Ed. I hope you are all looking forward to this week's issue...

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.

Some blog maintenance

Thu, November 1, 2007, 03:32 AM under Blogging
I've been running Live search on this blog for a year (well, December 2006 according to item 5 here). I've always had just the two search tabs ("The Moth" and "Web") and I just added two additional tabs (i.e. the option to search additional places with one hit) for "MSDN" and "MSDN Forums". Check it out on the left! To see how to do the same for your blog/site, see Scott's post.

BTW, I took the opportunity to change the order of the sidebar and the main column. This won't have a visual effect on the desktop, but will eliminate all that scrolling on mobile browsers ;-). Please let me know if I broke anything...