Thursday, March 20, 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.
Labels: Orcas
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 :)
Labels: Orcas
Monday, February 25, 2008
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.
Labels: Orcas
Saturday, February 23, 2008
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.
Labels: Orcas
Thursday, February 21, 2008
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.
Labels: Orcas
Monday, February 11, 2008
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.
Labels: Orcas
Wednesday, January 16, 2008
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.
Labels: Orcas
Tuesday, December 11, 2007
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.
Labels: Orcas
Monday, December 10, 2007
Tuesday, December 04, 2007
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).
Labels: Orcas
Tuesday, November 27, 2007
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:

Labels: Orcas
Monday, November 26, 2007
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.
Labels: Orcas
Saturday, November 24, 2007

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.
Labels: Orcas
Friday, November 23, 2007
Thanks to one of my readers (Martin Normak) for pointing this out to me.
Labels: Orcas
Thursday, November 22, 2007
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.CurrentSo 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.
Labels: Orcas
Wednesday, November 21, 2007

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.
Labels: Orcas
Tuesday, November 20, 2007
Tools -> Options -> Text Editor -> HTML -> Validation

...enjoy the two new checkbox Options to treat errors as warnings :-)
Labels: Orcas
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>Easy once you know how ;-)
<ul class="myCSSrule">
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
Labels: Orcas
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.
Labels: Orcas
Monday, November 19, 2007
Labels: Orcas
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.
Labels: Orcas
Friday, November 02, 2007
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.
Labels: Orcas
Tuesday, October 30, 2007
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.
Labels: Orcas
Labels: Orcas
Monday, October 29, 2007
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.
Labels: Orcas
Friday, October 26, 2007
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 ;-)
Labels: Orcas
Sunday, October 21, 2007
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.
Labels: Orcas
Friday, October 19, 2007
Labels: Orcas
Wednesday, October 10, 2007
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 ;-)
Labels: Orcas
Wednesday, October 03, 2007
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.
Labels: Orcas
Friday, September 28, 2007
Watch the screencast here.
Labels: Orcas
Tuesday, September 25, 2007
Labels: Orcas, ParallelComputing
Thursday, August 23, 2007
Wednesday, August 22, 2007
Labels: Orcas
Sunday, August 19, 2007
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 ;-)
Labels: Orcas
Saturday, August 18, 2007
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.
Labels: Orcas
Friday, August 17, 2007

(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.
Labels: Orcas
Thursday, August 16, 2007
Labels: Orcas
Labels: Orcas
Wednesday, August 15, 2007
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.
Tuesday, August 14, 2007
Labels: Orcas
Labels: Orcas
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 ;-)
Monday, August 13, 2007
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 ;-)
Labels: Orcas
Sunday, August 12, 2007
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.
Labels: Orcas
Saturday, August 11, 2007

Yup, automatic properties by default ;)
Labels: Orcas
Friday, August 10, 2007
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.
Labels: Orcas
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!).
Labels: Orcas
Thursday, August 09, 2007

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!
Wednesday, August 08, 2007
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.
Labels: Orcas
Tuesday, August 07, 2007
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.
Labels: Orcas
Monday, August 06, 2007
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?
Labels: Orcas
Saturday, August 04, 2007
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...
Labels: Orcas
Friday, August 03, 2007
[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 ListWhat 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.
Labels: Orcas
Thursday, August 02, 2007
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).
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...
Wednesday, August 01, 2007
Labels: Orcas
Labels: Orcas
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).
Labels: Orcas
Tuesday, July 31, 2007
Monday, July 30, 2007
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...
Labels: Orcas
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
Labels: Orcas
Sunday, July 29, 2007
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...
Labels: Orcas
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 Orcasto
# Visual Studio 2008If only everything was this simple...
Labels: Orcas
Saturday, July 28, 2007
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.
Labels: Orcas
Friday, July 27, 2007
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).

Labels: Orcas
Thursday, July 26, 2007
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).
Labels: Orcas
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 :-)
Labels: Orcas
Monday, July 23, 2007
Labels: Orcas
Wednesday, June 20, 2007
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).
Tuesday, June 05, 2007
.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 ;-)
Labels: Orcas
Monday, June 04, 2007

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.
Labels: Orcas
Sunday, June 03, 2007
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 ;)
Labels: Orcas
Saturday, June 02, 2007
Thursday, May 24, 2007
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.
Labels: Orcas
Sunday, May 20, 2007
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).
Labels: Orcas
Saturday, May 19, 2007
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.
Wednesday, May 16, 2007
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.
Tuesday, May 15, 2007

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 :-)
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.
Labels: Orcas
Sunday, May 13, 2007
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 ProgramYou will see a compiler error as follows:
{
//[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();
}
}
"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.CompilerServicesThen, wherever you declare the extension methods, optionally add to the top:
{
public class ExtensionAttribute : Attribute { }
}
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;...if you also add to the project this (demo) code file here.
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();
}
}
BTW, how soon are you guys out there planning to move your existing 2.0 projects to Visual Studio "Orcas"? ;-)
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 ProgramCan 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.
{
delegate T Func(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
Funcf = j => j + 1;
Console.WriteLine(f(5));
Console.ReadLine();
}
}
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.
Friday, May 11, 2007
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).
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.
Labels: Orcas
Thursday, April 26, 2007
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?
Labels: Orcas
Tuesday, April 24, 2007
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!
Labels: Orcas
Sunday, April 22, 2007
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.
Labels: Orcas
Friday, April 20, 2007
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.
Labels: Orcas
* 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 :-)).
Labels: Orcas
Thursday, April 19, 2007
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.
Labels: Orcas
Wednesday, March 28, 2007
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.
Labels: Orcas
Monday, March 19, 2007
Labels: Orcas
Saturday, March 17, 2007
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.
Labels: Orcas
Wednesday, March 14, 2007
Labels: Orcas
If you prefer exploring these things directly in Visual Studio look at the classes in the System.Security.Cryptography namespace in Core.
Labels: Orcas
Saturday, March 10, 2007
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!
Labels: Orcas
Thursday, March 08, 2007
var results =After the session one of the delegates asked me: "Why do we have to use the
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 };
equals keyword and not just ==". In other words he would have preferred to type: on p.ProcessName == p2.MyProcNameI 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.Tuesday, March 06, 2007
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 (

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!"
Labels: Orcas
"$(DevEnvDir)..\..\Common7\Tools\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" –outputresource:"$(TargetDir)$(TargetFileName)";#1In 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 manSecondly, 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."
/win32manifest:<file> Specify a Win32 manifest file (.xml)
/nowin32manifest Do not include the default Win32 manifest
Copyright © Daniel Moth


