Open Beta 1 solutions with Beta 2

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

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

If only everything was this simple...

Allow app to host WPF add-in

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

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

VS2008 Installation experience

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

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

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


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

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

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

LINQ to DataSet

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

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

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

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

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

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

dataGridView1.DataSource = results.AsDataView();

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

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

VS2008 Beta 2 with go live license

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

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

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

Our survey says... Mix:UK 07

Wed, July 25, 2007, 08:15 AM under Events
After the huge MIX event held in Las Vegas in May, dozens of great RE-MIX events followed around the world. In almost all of them, the content from the main MIX event was taken and delivered via mostly some local speakers presenting the existing material. You didn't need me to tell you that, the title of those events gives it away: RE-MIX.

Here in the UK we opted for a different approach. We waited (and waited) and found the perfect time to hold our 2-day MIX event: September 11 and 12. The reason we waited is that we wanted to have some fantastic announcements to make in addition to whatever took place in Vegas (and we do have some cool announcements in that timeframe!) and also we wanted to create new original content. That also explains that we are not RE-delivering content and the actual title of our event is Mix:UK

Today we opened registration. Spaces truly are limited (I think we missed a trick there by not finding a larger venue) so, for opportunities such as seeing Scott Guthrie delivering a few sessions, REGISTER NOW.

Also, the NxtGenUG boys would like you to fill in a free quick survey for the 'Swaggily fortunes' game taking place at Mix:UK – attending is not a prerequisite for completing the survey. You may even win a prize just by answering a few questions and remember that the answer to question 6 is Daniel Moth, go fill it in.

Facebook from .NET

Tue, July 24, 2007, 03:20 PM under MobileAndEmbedded | Links
It looks like the world has gone crazy with this Facebook thingy. I have zero time for real socialising let alone for online socializing so I have ignored the whole thing. By "ignored", I mean I have acted on invitations (meaning I had to create my space or whatever it is called) and other things that come into my email inbox, but I have not customised anything or initiated connections/invitations or even uploaded a photo. So why am I talking about it here?

It turns out that there is a .NET API for Facebook! It also looks like supreme device developer and all around top geezer, The Foot, has started porting it to support the .NET Compact Framework. Check out his blog post for more (which follows on from this one that includes screenshots).

Class Designer for C++ in VS2008

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

Vista ComboBox

Fri, July 20, 2007, 05:30 AM under Windows | Vista
Over time I've talked about XP and Vista textbox cue banners (and even implemented a version for Windows Mobile), but I hadn't realised they can be used for Vista combo boxes as well! The clue came via Kenny's MSDN mag article (includes many other features for the C++ Vista developer).

So all I had to do was the simple translation to managed code, which involves one line of code (assuming you have a combobox on your form with a few items to select and none set as selected):
SendMessage(comboBox1.Handle, 0x1703, 0, "Choose"); //CB_SETCUEBANNER

From left to right in the image above: Before the API call, before the call and the drop down open, After the API call, after the call with the drop down open. Of course once you select a real value from the combobox you do not see the cue banner (e.g. "Choose") again.

FYI, I actually found that any value for the two ComboBox properties DropDownStyle and FlatStyle worked, and the ones in the image above are DropDownList and System respectively.

Duck Typing

Thu, July 19, 2007, 03:15 PM under Links
Not sure how this term managed to escape me up to now, but it did. Simple stuff like this fascinate me. From wikipedia:
"In computer science, duck typing is a principle of dynamic typing in which an object's interface and attributes determine valid semantics, rather than having the language enforce rules regarding inheritance or require type casting."

Found via Krzysztof where he discusses Duck Notation.