See you at MIX or MEDC

Fri, April 27, 2007, 10:02 PM under Random
It is going to be busy for me at MEDC again this year (sessions one, two, three and four), but if you are attending MEDC or even MIX (which is also held at the Venetian in Vegas next week), contact me to catch up. I am flying there in a few hours and will stay until next Friday.

When I am back I'll share some good news even though somebody has already spilled the beans. Have fun!

MEDC Session 3 and 4

Fri, April 27, 2007, 07:52 AM under Events
Wed, May 2, 15:45 - 17:00, Room: Venetian F
Thu, May 3, 14:00 - 15:15, Room: Venetian F

APP206 & APP206R - Panel Discussion with .NET Compact Framework Team, OpenNETCF Smart Device Framework Team and Other Industry Insiders

Do you have pressing questions about the .NET Compact Framework? Do you use OpenNETCF's Smart Device Framework and have specific questions? Do you have general questions on Windows Mobile and Windows Embedded CE development? Come to this session where members of the Compact Framework Team, OpenNETCF's Smart Device Framework team and other industry developers will be part of a panel answering questions from general coding to architecting mobile software, even covering .NET Micro Framework.

MEDC Session 2

Fri, April 27, 2007, 07:50 AM under Events
Wed, May 2, 11:30 - 12:45, Room: Veronese 2404-05-06

APP312 - Sharing Assets Between the .NET Compact Framework and the .NET Framework

Whether you were first introduced to .NET via the Compact Framework in Windows Mobile or via the full .NET Framework on the PC, it may make sense to share your code assets between the two platforms. In this session we will explore when you should be doing this and when not. We will then explore the options available (e.g. directly sharing binaries or conditional compilation) and drill into problems and workarounds. This will include framework differences, platform/OS differences, optimal usage of Visual Studio 2005 (and "Orcas") and how things have improved since NETCF v1 and v2 (going towards v3.5).

MEDC Session 1

Fri, April 27, 2007, 07:48 AM under Events
Tue, May 1, 15:15 - 16:30, Room: Venetian G

APP203 - Building Mobile Windows Forms Applications: Tips, Tricks and Guidelines

When managed code first came to devices, there was a lot of excitement because developers finally had the ability to make use of their existing skills and assets from the desktop world, into the Windows Mobile world. The truth is that building GUI applications for Windows Mobile, is not the same as building GUI applications for your PC or laptop. In this demo-driven session, we explore the platform differences between desktop and mobile, and also explain what you must do to address them. In addition to explaining best practises for building mobile applications for mobile users, we look at the UI guidelines for Windows Mobile and map those to the code required for meeting them. You will also gain an understanding of what is required in order to write cross-device code including what Windows Forms controls are best avoided and how to overcome potential .NET Compact Framework limitations.

Programmatically determine if UAC is enabled

Thu, April 26, 2007, 07:38 PM under Windows | Vista | UAC
This is a question I get often:
"How can I determine if User Account Control is on or off via code?"
The answer I always give:
"You are asking the wrong question. Who cares?"
The point being that, regardless of whether the user has turned off UAC or not, your application should still be partitioned and work correctly for both admins and non-admin users. It is irrelevant if UAC is on or off. You should still display the shields, you should still gracefully fail if the user is not an admin (same as you would if the elevation prompt came up and the user cancelled, same as you should if you were running on XP). The academic answer to the original question is that you can read it from the registry (much like the built-in Security Centre does). Since there is no genuine requirement to know this stuff from code, there is no API for it.

So the only question to answer programmatically is how to know if the user has admin rights. I have shown how to do this before but here goes again:
 // using System.Security.Principle;
private bool IsAdmin()
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal p = new WindowsPrincipal(id);

return p.IsInRole("Administrators");
I have read blogs where others get further information regarding elevation about the user's account by pinvoking native APIs, but again, I remain totally unconvinced about that need. Your app shouldn't care about anything else: all that matters is if the user has admin rights at the moment your admin code is about to execute, nothing else.

If you disagree and think you have a genuine reason for knowing more than what I describe above, then please post your scenario to the relevant forum linked to from here.

Repaving and how VS Orcas saves me time

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

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

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

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


Wed, April 25, 2007, 11:06 AM under Windows | Vista | SideShow
At some point I must find time to continue my series of blog posts on the Windows SideShow technology that ships with Vista. But until then, if you've wanted to play with this stuff but couldn't be bothered to download the Windows SDK (shame on you btw!), now you have the option of downloading the Device Simulator as standalone (and it is a newer version too!). Go get it.

Transparent Intellisense

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

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

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

Orcas Office development through pictures

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

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

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

For Office 2003 project templates, see this screenshot.

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

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

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

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

Click for screenshots of STEP 2 and of STEP 3.

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

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

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

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

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

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

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

VB intellisense in Orcas

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

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

...when you then continue to declare the type of the variable, it will help you again: comes into its own with the new LINQ syntax:

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

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

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

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

Aesthetic and usability in Orcas B1

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

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

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

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

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

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

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

Get Orcas Beta 1

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

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

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

IL support by Compact CLR

Thu, April 19, 2007, 01:15 PM under MobileAndEmbedded
While chatting with users of a new .NET language that will RTM later this year (Vulcan.NET), I asked what they were doing for .NET Compact Framework support. They had most of it pretty much sussed. They understood that the tool support is the biggest hurdle since, at the end of the day, their language compiles down to IL so there should be no issues.

That last statement is true except the NETCF CLR only understands a (very rich) subset of the entire IL set. It doesn't support some niche opcodes mostly used by managed C++ (which the NETCF does not support). I promised I'd find the list of what is supported and what isn't. Dan from the NETCF team has posted such a table on his blog and even though it was written for v2.0 it still holds true for v3.5 of the NETCF. Check it out here.

UAC Elevation with COM

Thu, April 19, 2007, 01:05 PM under Windows | Vista | UAC
You've probably read my posts on UAC (tip: read bottom up), and in my talks I always explain how to factor out into separate processes any admin functionality.

What I've never explained is how to factor into out-of-proc COM objects the admin functionality. Christoph has explained that on his blog and has done it all in managed code no less! Check his posts out starting here (and follow his links for the rest).

Bridge in Glidepath

Thu, April 19, 2007, 12:27 PM under Windows | Vista
By now you all know about the VistaBridge sample that is part of the Windows SDK. I hope you also know about Project Glidepath. Apparently, the guys behind glidepath thought it was too much effort for a developer to have to type code that simply sets properties like the code shown here, so they created a package where you simply make selections with the mouse and the code gets spat out for you!

Definitely worth watching the 5 minute screencast (follow their link).

Microsoft Jobs

Thu, April 19, 2007, 12:21 PM under Links
Steve is giving up his job. If I ever decide that I am fed up of so many in-person events and would like to shift the bulk of my efforts to writing, I would go for this one. Imagine contributing in more ways than one to every issue of the world's best developer magazine on the Microsoft platform!

The other one is not a specific role but boy does Mike sell the MED division well! I tell you what, I am tempted already...

If the two above don't take your fancy, check out the full list (it is free to register).

Outlook rules

Thu, April 19, 2007, 11:53 AM under Communication
After a long period offline on holiday, I returned to all my inboxes overflowing with email - none more than my work email account. It has taken me about 3 days to address everything emailed to me, but that is another story. There are many factors to receiving tons of email and I could easily rant about people CC'ing me for no reason whatsoever (or rant about those asking for read receipts, wot's up with that?).

However, the one that really ticks me off is people that BCC me: I call those people BCCards (pronounced slightly differently than what it is spelled). BCCing also happens when someone decides to add a bunch of distribution lists (DLs) to the BCC field thus avoiding my carefully constructed Outlook rules for categorising posts to DLs into their own folders. It also happens when someone sends an email to a DL that I have not subscribed to but that is a member of some larger DL that I have no interest in. So how can I deal with this issue and avoid the useless message from landing in my inbox directly? Annoyingly, I cannot find a rule that I can create in Outlook to cope with this situation, so I had to take a number of steps. If you know of a better way please let me know and if you don't, then I hope you appreciate my approach (works with Outlook 2007).

1. Go through all the existing rules and make sure that in the Actions (step 2) you have checked the "stop processing more rules" action.
2. Create a new rule and move it to be the last rule of them all (FYI rules get processed in order). Do not create a condition for this rule, and go straight to step 2 on the actions. Check the "Permanently Delete it" box. AND then move to the next page on Exceptions and check the "except if my name is in the To or Cc" box.

I won't tell you how close I came to also doing the above for messages marked with "High Importance". Have you ever received a message that had this set and was truly important? Have a look in your inbox now and check to see which messages are marked as such. Looking at mine, it seems that the messages are not important but the people that send them think they themselves are...

Off to plan a Greek wedding

Sun, April 1, 2007, 07:57 AM under Personal
I am off to Greece for a couple of weeks on holiday. Well, I say holiday but actually it is to sort out some stuff for our Greek wedding (the religious version)... for those that haven't done it yet, planning a wedding is time consuming in its own right, but planning one remotely is very stressful indeed - my advice is simply don't!

Anyway, normal business will resume on April 17th or thereabouts...