MSDN Flash 31 Oct

Wed, October 31, 2007, 07:59 AM under Links
The MSDN Flash was just delivered (subscribe here). The Fresh discoveries include "Oslo" and the editor's Intro may have the bag let the out cat ofyou can view this issue online now.

SCF intellisense

Wed, October 31, 2007, 02:59 AM under SideShow
It has been a while since I blogged anything about SideShow but it occurred to me recently that when I was throwing together the SCF XML for my SideShow screencast, I never used the schema to get intellisense for it because I was using the managed API. However, just because you can use the managed API to generate the SCF for you doesn't mean you cannot use the SCF schema to get intellisense and create the SCF that way (and then use the managed API to send it down). All you need is the XSD file and then to use Visual Studio's schema support.

Step 1: Get SCF schema from here. Plug it in as per usual and notice how you get compiler errors.
Step 2: Fix the error you get by changing this <xsd:complexType name="ItemType" mixed="true"> to this <xsd:complexType mixed="true">.
Step 3: At this point you notice that intellisense works great but it allows you to start with any element, and not just with the only legal SCF option which is body. Not being an XSD person I kindly asked the XSD Jedi to refactor the schema so it can only start with the body element – luckily he obliged.
Step 4: So intellisense worked fine at previous step (thanks Dave), but I still wanted to have comments. So I manually populated the schema with comments and now I have a really cool SCF XSD schema with rich intellisense:

Download the xsd here.

XML Schemas dialog in Visual Studio 2008

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

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

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

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

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

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

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

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

New in CardSpace with Fx 3.5

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

ASP.NET for Windows CE

Tue, October 30, 2007, 02:11 AM under MobileAndEmbedded
Three years ago I was speculating about this very topic, and was planning to implement it for the company I worked for at the time. I never got the chance, but the OpenNETCF guys delivered Padarn today! Very cool...

VS2008 for web developers

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

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

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

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

Support for Nested Master Pages in VS2008

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

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

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

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

Orcas Beta 2 VPC expiration in a week

Thu, October 25, 2007, 03:05 PM under Links
I don't like "me too" posts but this is important, especially since I am responsible for some of you downloading it: If you are running VS2008 Beta 2 in a VPC, it will expire November 1st. Full details on JeffBe's blog.

My November Events

Thu, October 25, 2007, 02:20 AM under Events
Same intro/outro as my post on Sept and Oct events. Hope to see you at one of these:

+ 1st, Coventry, VBUG, Details and registration.

+ 3-10, Barcelona, TechEd, Details and registration.

+ 13th, Brighton, VBUG, Details and registration.

+ 15th, Southampton, NxtGenUG, Details and registration.

+ 20th, Cambridge, NxtGenUG, Details and registration.

+ 24th, Reading/TVP, DDD6, Details and registration.

+ 27th, London, LDNUG, Details and registration.

+ 29th, Bristol, MSDN, Details and registration.

PIP in screencasts?

Wed, October 24, 2007, 04:30 AM under Random
ScottHa asks for your opinion on the usage of Picture-In-Picture (PIP) for screencasts. If you haven't seen that before, it is where not only you see the presenter's screen but you also see the presenter's "talking head" in the corner of the video. As someone who believes very strongly in the power of screencasts, I'd also be interested in what you think about PIP so head over and scroll down to the Screencast survey and then drop a comment.

Personally I don't like PIP, but if you do then I may consider including a PIP in my screencasts. I find the head distracting plus it makes the file grow larger and I try to keep the wmv as small as possible. The last reason I don't like the PIP, is because when I record these I am at home in a far from presentable appearance ;-).

Five VSTO v3.0 (in VS2008) videos

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

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

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

WPF from WinForms in VS2008

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

MSDN Flash 17 Oct

Wed, October 17, 2007, 09:10 AM under Links
The MSDN Flash was just delivered to its subscribers. There were 15 Fresh discoveries and an opportunity to win an Xbox Elite 360 – you can view this issue online now.

Going to Tech Ed Europe 2007? Come to my sessions and win

Mon, October 15, 2007, 02:33 PM under Events
UPDATE: Fixed room info.

In 3 weeks in Barcelona the largest Microsoft conference of the year takes place. If you haven't chosen sessions to attend yet, go do it now that the agenda is live with all the info (assuming you have registered).

This year Tech Ed is 5 days long, so I am delivering a session per day. At each session I will be handing out a copy of my book as a prize signed by all 3 authors! That is a total of 5 opportunities for you to win it. Below are the times and rooms where you can attend (all sessions 75' long):
  • Monday 5th, 16:00, Auditorium, TLA201
    A Tour of Visual Studio 2008 and the .NET Framework 3.5

  • Tuesday 6th, 10:45, Room 113, MED202
    Building Mobile Windows Forms Applications: Tips, Tricks and Guidelines

  • Wednesday 7th, 09:00, Room 130, MED304
    Sharing Assets Between the .NET Compact Framework and the .NET Framework

  • Thursday 8th, 13:30, Room 113, WIN312
    Windows Vista for Managed Developers: Besides .NET Framework 3.x

  • Friday 9th, 13:30, Room 121, MED01-PAN
    Windows Mobile Application Development Panel Discussion
Note that TLA201 is in the keynote room so plenty of space for all that wish to attend ;)

MS Speak RC Build 21004.01

Fri, October 12, 2007, 07:00 AM under Random
Mike, I find it very British of you to question the Microsoft speak!

SO, my ASK to you is to GO AHEAD and get SUPER excited about how much more PERFORMANT your developer STORY becomes with these UM.. UM... enhancements that we are BAKING into the language. See it as your CALL TO ACTION. :-)

WPF and Windows Forms integration

Wed, October 10, 2007, 02:23 PM under Orcas | VisualStudio
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 ;-)

Releasing Source Code for the .NET Framework

Wed, October 3, 2007, 10:09 AM under dotNET
Huge announcement today: Microsoft is releasing the source code for parts of the .NET Framework (inc. BCL, WinForms, WPF, ASP.NET) under the Ms-RL license which effectively, by my interpretation, means that you can read but you cannot copy or modify.

The cool bit is not that you can just read the framework code in your favourite text editor once you download and accept the license; no, the real goodness is that when you debug your applications with Visual Studio 2008 you will have the option to debug right down into the Framework code (with an autodownload feature from an MSDN server)! Are you still debating the move to VS2008? ;-)

For more details read ScottGu's blog post or listen to ScottHa's podcast or watch ch9 interview with the man that made it happen.

FxCop rule for red bits

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

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

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

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

Migrating from .NET Framework v1.x to Visual Studio 2008

Mon, October 1, 2007, 01:38 AM under dotNET
I have no reservations in describing the move from Visual Studio 2005 to Visual Studio 2008 as a "no-brainer upgrade". The latter is a superset of the former and given framework multi-targeting and the layered approach of Framework 3.0 and 3.5, it makes perfect sense to move your development environment over and, when you are ready to change your deployment, seamlessly take advantage of a new .NET Framework 3.x

But how about those people still using VS.NET 2003 (shocking I know :) who wish to take advantage of the VS2008 enhancements and move closer to our latest platform? That's a different kettle of fish. The issue there is that: you are on a different CLR version (1.1) which has some breaking changes compared to the CLR 2.0 (which is used by Fx 2.0/3.0/3.5). You are also on a different framework version (1.1) which has some breaking changes compared to Framework v2.0 (which is also an essential part of Fx 3.0/3.5). There is no reason for you to go to VS2005 as an intermediate step, so by all means go from the IDE of 2003 to 2008, but be prepared to face all the issues people faced when they moved from Fx 1.x to Fx 2.0.

I thought I'd resurface below some links to documents that help people move from v1.x to v2.0, the first two being the most important ones IMO:
- Design time Breaking Changes in .NET Framework 2.0
- Runtime Breaking Changes in .NET Framework 2.0
- Microsoft .NET Framework 1.1 and 2.0 Compatibility
- Compatibility Testing Scenarios

Also note that if you search you'll find plenty of issues in particular for web projects since the project model fundamentally changed from VS.NET 2003 to VS2005. It was later amended via separate downloads for VS2005 but since you are moving to VS2008 you don't have to worry about that (both web site projects and web application projects are included out of the box with VS2008). So, just one extra link for you pre-ASP.NET v2.0 devs:
- Feature changes in ASP.NET 2.0

A much older blog post on the same topic may also be of use to you.