MVP Summit 2007

Sun, March 11, 2007, 02:09 PM under Random
One of the perks of being an MVP (and the perk I miss the most!) is attending the global MVP summit in Seattle (and I did that in 2005). Having been to plenty of public conferences and also to internal Microsoft conferences (MGX, TechReady), let me share with you that the MVP summit tops them all. It is simply the one to be at! To everyone out there this coming week, have one on me :-)

I was going to try and make it there this year, in a different capacity of course, but my speaking schedule got in the way :(

Installation of March CTP on Vista

Sat, March 10, 2007, 04:02 PM under Orcas | VisualStudio
The point of this post is: do not install the Orcas March CTP side by side with VS2005 on Windows Vista.

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!

NETCF SP2 ships

Fri, March 9, 2007, 08:40 AM under MobileAndEmbedded
I am late with this news (stuck in a place with no network connection).

Build 7045 (ie 2.0.7045.0) of the .NET Compact Framework is out of the door. No need to copy/paste here what is fixed since it is described on the download page.

One of the big ones is new diagnostics (that finally work on Vista) and, as usual, Steven has all the details.

equals versus ==

Thu, March 8, 2007, 03:09 AM under Orcas | LINQ
At a recent event where I was presenting on LINQ, I showed a query with a join, similar to the following:
      var results =
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 };
After the session one of the delegates asked me: "Why do we have to use the equals keyword and not just ==". In other words he would have preferred to type:
on p.ProcessName == p2.MyProcName
I 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.

VS2005 SP1 Update for Vista

Tue, March 6, 2007, 03:34 PM under Windows | Vista
Following the SP1 for VS2005, the update for Windows Vista is now also available. Get it here (especially if you are doing web development on Vista).

This is what my VS about box looks like after I installed it:


Also see Soma's relevant Q&A.

NetFx support in VS Orcas

Tue, March 6, 2007, 04:55 AM under Orcas | VisualStudio
UPDATE: After Beta 1 I updated the screenshot below (you can still view the old one here).

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 (which I am guessing many will since the version dropdown is in a non-obvious place IMO), then you can change the platform later via the project properties under the Application tab:

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!"

Embedding manifests in Orcas

Tue, March 6, 2007, 04:45 AM under Orcas | VisualStudio | UAC
The first thing you should do with your applications on Windows Vista (and indeed a logo certification requirement) is embed a manifest in your application that effectively tells Windows that your app is aware of User Account Control. I have explained how to do this with VS2005 here. Also Catherine listed a few ways here. Bottom line: create a manifest like this, and embed it in your project with a post-build command: "$(DevEnvDir)..\..\Common7\Tools\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" –outputresource:"$(TargetDir)$(TargetFileName)";#1

In 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 man
/win32manifest:<file>   Specify a Win32 manifest file (.xml)
/nowin32manifest        Do not include the default Win32 manifest
Secondly, 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."

Microsoft.VisualStudio.Shell.WindowPane.OnCreate

Tue, March 6, 2007, 04:21 AM under Orcas | VisualStudio
"An error occurred trying to load the page." is what I encounter in my "Orcas" installation whenever I try to open the project properties grid/designer as captured in the following image:


In case you are facing this too, it is a side by side issue with VS2005. If you've only installed Orcas on your box without VS2005 (or downloaded the VPC image) then you will not have this issue. Sorry, no workaround for now, but fixed for future builds.

This blog entry also explains why some screenshots of the property pages that I am about to post are from my VPC WS2K3 Orcas installation rather than my Vista installation like my other screenshots :)

Automatic properties in C#3

Mon, March 5, 2007, 04:36 AM under Orcas | VisualStudio
I was looking at Ander's slides from Tech Ed Europe and he had one about automatic properties but watching the video he did not cover that in his session. It is the simplest concept imaginable and hence it deserves a simple short blog entry.

In C#3, you can write code like this:
        public string Name
{
get;
set;
}
The compiler generates code like this:
        private string XX;
public string Name
{
get { return XX; }
set { XX = value; }
}
, where XX is not directly accessible to you in code of course. This only works for properties with both getter and setters.

Get the March CTP to try it out yourself.

Administrator in VS Orcas title bar

Mon, March 5, 2007, 04:11 AM under Orcas | VisualStudio | UAC
Anyone running on Vista knows about the new security feature of UAC. A known trick is to right click on a command window shortcut and select "Run As Administrator" to get an elevated command window.


Following that, anything you launch from the elevated cmd will also be elevated. Of course this can be dangerous so when a command window is elevated, it is prefixed with the word "Administrator" (so you can distinguish it from non-elevated command windows).


No other window on Vista will tell you in its caption that it is running as administrator. The reason for that is that you will not typically run an interactive process elevated for a long period of time plus most apps cannot do the accidental damage that an elevated cmd window can. Of course each application developer can decide for their own app what they want to do.

The VS Orcas team decided that they wanted to differentiate an elevated VS instance from a non-elevated instance. They do this by appending a "(Administrator)" string on the title as the following screenshot shows:


I like this, although I would have also liked some consistency between cmd and VS and in fact maybe some official Windows guideline that all apps follow.