Orcas – another round of VS improvements

Orcas – another round of VS improvements

I’ve finally got around to running the Microsoft Pre-release Software Visual Studio Code Name “Orcas” – September Community Technology Preview (CTP). Big thanks to Mauricio who downloaded the image (my Woosh account is tooo slow to download anything over 10Mb) for me.

Device Security Manager
One of the first features I was eager to look at was the integration of the Device Security Manager (Windows Mobile Powertoy) into the IDE. the DSM is available from the Tools menu and renders within the VS IDE. After connecting to a device/emulator you can export/import security configurations from the device. These are xml scripts like the following, that can be applied to the device/emulator.

<wap-provisioningdoc>
   <characteristic type=”SecurityPolicy”>
      <parm name=”4123″ value=”0″ />
      <parm name=”4122″ value=”1″ />
      <parm name=”4101″ value=”16″ />
      <parm name=”4102″ value=”0″ />
      <parm name=”4097″ value=”2″ />
   </characteristic>
</wap-provisioningdoc>

Note, as you play with this feature you might notice that the toolbar for the DSM occasionally displays options to Add/Remove certifications – perhaps this is a hint as to what is to come.

Smart Device Testing
When VS2005 was released there was great disappointment from the mobile developer community as we were severly neglected when it came to SDLC support in Team System. Although we could check out projects into TFS we couldn’t use any of the automated testing. In this CTP we have the first sneak preview of the testing support that is going to be built in. To create tests for a smart device project you simply right click on the method and select “Create Unit Tests…”. Be sure to select the “Create a new smart device test project” – if you don’t the tests will not be executed on the device. Also, be warned that running a smart device test will NOT deploy the .NET framework runtime to the device. To do this you can either manually install it from the redistributable, Or you can just run a .NET device application from the VS IDE – this WILL deploy the runtime to the device.

The Digital Native Platform

The Digital Native Platform

Mitch has an interesting concept with his proposed Digital Native Platform.  This is an interesting, albeit not new, concept.  I seemed to remember sitting through a tour at Microsoft at the last MVP summit where we saw similar technology and the dream of a paperless office where collaboration was the key to a successful business.  Regardless I still think it is worth throwing away the printer and seeing just how far you can go.

Splash screens using VB2005 Application Framework

Splash screens using VB2005 Application Framework

James Avery makes a point that Eric Gunnerson has a way of doing splash screens.  Unfortunately he has overlooked to easiest way to do splash screens which is to use VB.NET and set the splash screen form using the Project properties window.  It’s as simple as 1) Enable application framework 2) Set splash screen to the form you want to load.

Oh, as an aside, if you want to control the minimum time that the splash screen loads for all you need to do is trap the application load event (select “View Application Events” from the Application tab on the project properties page, then select the appropriate event (ie Startup) from the combobox) and set the My.Application.MinimumSplashScreenDisplayTime property to the number of milliseconds you want the screen to show for.

VB.NET needs Iterators

VB.NET needs Iterators

Just reading through the RSS sample I mentioned in my previous post on the Windows RSS Platform and noticed that they are using one of the new C# features in .NET v2, Iterators.  Anyhow the code snippet I’m referring to is:

public static IEnumerable<IFeed> CommonFeedList(IFeedFolder folder)
  
{
      Queue<IFeedFolder> queue = new Queue<IFeedFolder>();
      queue.Enqueue(folder);
      while (queue.Count > 0)
      {
         IFeedFolder currentFolder = queue.Dequeue();
         foreach (IFeedFolder subfolder in (IFeedsEnum)currentFolder.Subfolders)
            queue.Enqueue(subfolder);

         foreach (IFeed feed in (IFeedsEnum)currentFolder.Feeds)
         {
            System.Windows.Forms.Application.DoEvents();
            yield return feed;
         }
      }
   }

While not the most elegant piece of code (especially the explicit call to “DoEvents”) it got me thinking about how I would do this in VB.  The long answer is that you need to code the full iterator yourself.  Please, please, please VB team can we have iterators?

Joining the IE7 bandwagon

Joining the IE7 bandwagon

Over the last couple of days over half the blogs that I subscribe to have reposted the fact that IE7 has RTM’d.  Of which probably the best blog to read is probably Sandi’s as she is definitely one of the leading authorities on things IE. Not being a big fan of reposting I thought that I would provide a different angle on the release of IE7.  As most people will be aware of is that IE has RSS feed reading capabilities built in.  A feature that some people won’t be aware of is that this uses the Common Feeds List which a number of Microsoft products going forward will be using.  These products include Outlook 2007 and Windows Live Mail Desktop.  The built in functionality is more than just a local store for RSS feeds, it also have built in scheduling to synchronise the feeds and the ability to track which feeds/items have been read. Although the interface in IE7 is very rudimentary the support through Outlook 2007 is very nice indeed.

Of course the next question is whether there is an API for accessing this feeds store.  Well the great news is that Microsoft have come to the party with a quite extensive API, including documentation and a C# sample to get you started.

OneCare v’s WMDC

OneCare v’s WMDC

Continuing on from previous post regarding the issues with OneCare, Trend and VPNs I have run into another problem with OneCare.  This time it is preventing the beta of the Windows Mobile Device Center from connecting to my mobile device (or perhaps that should be my mobile device from connecting to WMDC).  Note that this behaviour is consistent with the default Windows Firewall that ships with Vista.  This leads me to believe it is probably an issue with WMDC rather than explicitly OneCare; However, it is an issue that both teams need to address.

UMPC – retail or enterprise

UMPC – retail or enterprise

Hugo and Dr Neil talk about whether UMPC devices should be a retail (ie appearing in Harvey Norman) or an enterprise device.  While Dr Neil argues that the target price point should be around the US$700 price point so that they are appealing to consumers I’m not convinced that these devices are going to sell like hotcakes even if the prices was $3-400.  Consumers (and I take a family as a typical representation here) will buy a desktop computer for use by the whole family rather than a mobile device that can easily be misplaced.  For those members of the family, such as the kids, that need a computer for school, a convertible tablet is probably going to be the device of choice.

On a different note, Hugo makes the point that he doesn’t think consumers will adopt UMPC devices as the learning curve is too high.  My thoughts are that in fact most consumers will understand the interaction model, using touch or stylus input, much better than the traditional mouse and keyboard.  I think acceptance will be high for the operating system; However I feel that unless us developers start to build applications that work with a touch/stylus input, these devices will struggle to be accepted by either consumers or the enterprise.  In fact I would go so far as to say this is the major impediment, especially when even Microsoft can’t get it right!

OneCare beta prevents VPN connections in Vista RC2

OneCare beta prevents VPN connections in Vista RC2

In my previous post I mentioned the beta of Windows Live OneCare (v1.5) that I am running on my Vista RC2 laptop.  What I didn’t mention is that one of the annoying bugs that I have found is that it prevents VPN connections from working.  Perhaps I missed something but even after going in and explicitly allowing “Microsoft Virtual Private Networks” whereever I could find a reference, I still couldn’t get a VPN connection to work.  I actually thought it was a bug in Vista until I tried disabling the firewall in OneCare and the VPN connected perfectly.


Updated: There are actually two workarounds for this.  The first is to disable the firewall in OneCare and enable the Windows Firewall that ships with Vista.  This is just as secure, although it does leave the OneCare icon red, which bugs me.  The other workaround is to add port 1723/outgoing to the exceptions list.  This is in addition to the “Microsoft Virtual Private Network” exception (in the default list) mentioned previously.

Pc-cillin v’s OneCare

Pc-cillin v’s OneCare

Last week when I reformatted my laptop for the 6 billionth time I installed Vista RC2 – it must be ready to ship soon…. After less than an hour I had a clean install running Media Center so that I could once again kick back and watch TV.  However, this wasn’t the end of the road.  When Vista boots up the Security Center flags that there is no virus scanner installed.  You can easily navigate to the Microsoft site where they have a number of virus scanners available for download (they are all in beta at the moment until Vista ships).  Having previously followed this road with Pc-cillin on a previous build I figured it would be a pretty safe bet, so I went with that.


A couple of days later and I get an email inviting me to participate in the beta for OneCare, Microsoft’s entry into the Virus scanning/firewalling/backup etc.  From here things started to go bad – I went to uninstall Trend and completely forgot that it was a beta.  Instead of taking the safe option and uninstalling using “Run as Administrator,” I instead opted to just uninstall the product.  Unfortunately it crashed mid way through leaving the system with chunks of Trend stuck all over the walls.  Not only could I no longer remove the product (despite it appearing in the installed Programs list), I couldn’t even reinstall it (since it thinks it is already installed).  Of course there is no “repair” option on this installer – there is a reason why all good installers have a repair option!


Anyhow I thought that perhaps installing OneCare would clear out Trend.  Nope, it just made matters worse as it identifies Trend as a potential security threat.  To prevent further damage I uninstalled OneCare and tried a number of things to remove Trend.  In the end I had to run regedit and remove all keys associated with Trend (a painful 1 hour + process).  I then rebooted and still the Security Center things Trend is installed.  Luckily I was able to reinstall Trend so that the system was at least stable.  Then, using “Run as Administrator” I proceeded to uninstall Trend.


Finally, after all this I was able to successfully install the OneCare beta – which went on without a hitch and is running quite smoothly in the background.

Walking the walk of shame – when blogs get it wrong

Walking the walk of shame – when blogs get it wrong

Ok, so I really should have done a bit more research prior to blogging my frustration around the apparent lack of support for VB in the first release of WPF/e.  It turns out that I was wrong (yes I’m big enough to walk the walk of shame on this one) and that I jumped the gun.  According to sources within Microsoft there will be Managed Code Support in WPF/e which will include both C# and VB.NET.  Way to go team – I’m so hanging out for this one.

Screen Resolution – how small should we go

Screen Resolution – how small should we go

Ok, so a long time ago I had a discussion with the other co-founders of PISCES communications around what screen resolutions and colour depth we should be supporting. At that stage we were arguing over whether 640×480 or 800×600 was the most common resolution.  Of course things have changed with monitors that are much bigger (physically) and support for much higher resolutions.  However, with Tablet PCs, and in particular UMPC devices, there has been a shift back to lower resolutions.  To this end a screen resolution of 800×600 is quite common for a number of smaller devices. 


The other really cool thing about Tablet PCs is that they open up a world of human interface options, such as writing and voice.  Unfortunately, as Craig points out here, the speech recognition team working on Vista has decided that voice is unimportant for users with a screen resolution less than 1024×768.  Rob Chambers indicates that asthetics was the ONLY reason they made this decision – how bad is that. 


Craig follows up by hitting the nail on the head – Developers don’t assume any minimum resolution (where possible) as you will always be wrong and frustrate your users.  Make your forms resizable, or at least if they are fixed width/height make them small!!!

WPF/e defining some language priorities (aka web developers use c# not VB)

WPF/e defining some language priorities (aka web developers use c# not VB)

I was chatting with Darryl this afternoon at the weekly Geekzone catch up and he was filling me in on the progress of Windows Presentation Foundation Everywhere.  Well, it turns out that support for mobile device will be shipping in V2, which is not surprising as this was stated early on by the team.  However, what was a massive surprise, and IMHO a complete insult to the thousands of VB developers, is that only Javascript and C# will be supported for writing client side code to run on the WPF/e runtime. That’s right apparently support for VB.NET will not make it into V1 – backlogged to V2.


THIS IS JUST WRONG – Microsoft should reconsider this, delaying shipment of WPF/e if necessary to guarrantee support for VB.NET


Updated: VB will be supported in the first release (see comments)

Vendor Presentations/Interviews

Vendor Presentations/Interviews

One of the problems with interviewing a vendor representative is that it is easy for them to drop into “salesman speak”. In the latest Arcast, Ron talks with Compuware representative, Sean Salisbury. Although there is the occasional product plug, it is intermingled with a number of great hints for successful development processes. These include integrated build testing (you mean your tests aren’t already run as part of your continuous build?) and performance analysis.

Speaking of performance analysis, JetBrains have been working on version 2 of their dotTraceTM Profiler. Last week we were having some issue with form load time so we downloaded the beta and within minutes we had tracked down some of our performance bottlenecks to the Infragistics grid control. More specifically the way we were using its stylesheets. Now that we know where the issue is we can work to reduce the load time. We want to keep using this grid control as it provides all the features we need in a data grid (such as headers, footers, styling and grouping with totals). So, the options are either to complain to Infragistics and see if they can tell us how to get around the issue, or, we can remove the bottleneck by putting it on a less critical path.

The idea of critical path in software is a concept that I think more development teams should investigate. By critical path I am generally referring to the user experience and everything that needs to go on to enable the user to work with the application. In the same way that you would minimise project risk by reducing the number/length/risk of items on the critical path, so too should application developers look to remove items from the critical path in their applications.

Take the example with the Infragistics control. The critical path here is that the user clicks a button and a form displaying a grid of data needs to be displayed (obviously in the shortest amount of time possible). There are a number of things that need to happen here: the form needs to be instanced, the grid needs to be created, the style sheet needs to be created from a resource file, the data needs to be loaded, the data needs to be bound to the grid, the form needs to be rendered. Using the profiling tool we were able to deduce that loading the style sheet is a major bottleneck on this critical path (at the moment all these actions happen in serial). If we can either pre-load this style sheet, or load it in parallel, we are likely to see a reducing in the load time for this form.

[OT] Whinging Australian farmers

[OT] Whinging Australian farmers

Ok, firstly before I go further on this post I would like to apologise to any farmers who are reading this post and feel that I’m out of line with these comments. I acknowledge that I’m neither a farmer or an environmental expert and I welcome any feedback to enlighten me.

I have just been listening to the Australian world news (thanks to the ABC’s podcast series) hearing about how the Australian farmers are all hard done by and that the recent lack of water has meant that they may have to run livestock instead of crops. Ok, correct me if I’m wrong but Australia is predominantly a dry continent, and most of the crops and livestock are not native to Australia. Subsequently we run into issues such as drought and salinity…..

You would think that one of the best ways to tackle this would be to start farming native plants and animals. For example, farming Kangaroos – this is seen as taboo because it is one of our national icons. The reality is that in some areas the number of these animals actually makes them a pest; although the flavour of the meat is more gamey it generally means you eat less of it (potentially less obese people???) and they have skin/fur that can be used for clothing and fashion items.

Anyhow, before you start emailing the government in support of our whinging farmer, take a thought about whether money will fix the underlying issue facing the Australian primary industry sector!

Project Glidepath

Project Glidepath

Having recently installed Vista RC2 I have been eagerly installing all my favourite applications: Office 2007, Visual Studio 2005, Orcas VS extensions, WF designer extensions, Live Messenger, Guidance Automation Extensions/Toolkit. Most of these installed without a hitch, although I did get continually prompted to allow Administrative permissions. Note: I did NOT have to disable User Access Control (yet).


Yesterday I got an email from the Project Glidepath team announcing that v2 is now available for download, so I eagerly downloaded it. After installing the Guidance Automation Extensions (although they include the Dec 2005 release, I had already installed the most recent release) I proceeded to install Project Glidepath. Half way through the install fails, “Error 2869”. This seems to relate to the infamous User Access Control(UAC). Work around is to create a batch file with the following lines:


msiexec /i ProjectGlidepathRepositoryManagerSetup.msi
msiexec /i ProjectGlidepathMicroISVFactorySetup.msi


Then right-click the batch file and select “Run as Administrator”. This will get the installer to work. However, the UAC issues are not over yet. The post-installation instructions suggest running Visual Studio 2005 and creating a new Project Glidepath project, from which you can “update” to retrieve the latest guidance information. Unfortunately, what they don’t tell you is that you MUST run Visual Studio as administrator, otherwise the database can’t be created and you won’t be able to update. Again, this can be done by right-clicking on Visual Studio 2005 in the start menu and selecting “Run as Administrator”.


Well, back to “synchronising” project glidepath – will hopefully have an update as to what is actually included once this has completed.

Occasionally Connected Systems Sync Framework

Occasionally Connected Systems Sync Framework

Earlier this year Microsoft announced that they would be re-banding SQL Mobile to SQL Server Everywhere. One of the ideas behind this initiative is to provide a better story for developers who want to build applications that support working in disconnected, or occasionally connected, mode. In the past the only solution in Microsoft-Land was to use either Access or MSDE (now SQL Server Express), neither of which provided a suitable solution. Access requires an Office license, while MSDE/SQL Express runs as a background service making it unsuitable for a single application local datastore. SQL/e addresses this issue as it runs in-process with the application. It will also be able to be deployed alongside the application using ClickOnce deployment.

One of the issues with using SQL/e as an offline datastore is that configuring merge replication was difficult and wasn’t always suitable, depending on the server datastore. As such the Smart Client data team at Microsoft have been working on a new sync framework. Steve Lasker has just posted a powerpoint presentation and a screencast that demonstrates where this technology is going!

VB.NET Event Handlers

VB.NET Event Handlers

I was just listening to Bill McCarthy chatting with Ron Jacobs on Arcast about the rich feature set of VB 2005.  One of the points of interest was around the declarative approach to event handlers that VB.NET uses.  For example say I have the following class with an event declaration:

Public Class ClassWithAnEvent

Public Event TestEvent As EventHandler

End Class

Now in VB.NET to wire up an object of this class so that I can receive notification on the TestEvent I can do it declaratively as follow:

Public Class ClassThatConsumesAnEvent

Private WithEvents x As ClassWithAnEvent

Private Sub TestEventHandler(ByVal sender As Object, ByVal e As EventArgs) Handles x.TestEvent

End Sub

End Class

The question is what does this do under the hood.  Well the easiest way to explain this is using our good friend, Reflector, to regenerate the code:

Public Class ClassThatConsumesAnEvent

<AccessedThroughProperty(“x”)> _
Private _x As ClassWithAnEvent

Private Overridable Property x As ClassWithAnEvent

Get

    Return Me._x

End Get

Set(ByVal WithEventsValue As ClassWithAnEvent)

    If (Not Me._x Is Nothing) Then

    RemoveHandler Me._x.TestEvent, New EventHandler(AddressOf Me.TestEventHandler)

    End If

    Me._x = WithEventsValue

    If (Not Me._x Is Nothing) Then

    AddHandler Me._x.TestEvent, New EventHandler(AddressOf Me.TestEventHandler)

    End If

End Set

End Property

End Class

As we can see from this code, VB.NET is doing a lot of the heavy lifting around adding and removing eventhandlers.  This means that we can easily reassign an object to variable x without having to worry about adding and removing eventhandlers.  This also clears up, for those that were wondering, where eventhandlers are added/removed in VB.NET.

Hiding my password

Hiding my password

Following Alastair’s post regarding encrypting sections of a configuration file I ran into a similar issue where I wanted to protect a password that my application was using.  Obviously there are a couple of big NO NOs. I can’t hard code the password into the application because it is too easy to use something like Reflector to crack it own and grab the password in clear text.  I can’t easily use the standard crypto functions that require a private key, cause then I would have to hide the private key somewhere).  Luckily v2 of the .NET Framework exposes DPAPI through the ProtectedData class.  As such I can do the following to encrypt/decrypt data:


    Private pData As Byte()
    Private Sub Encrypt()

        Dim sensitiveData As Byte() = System.Text.Encoding.Unicode.GetBytes(“Some sensitive data”)
        pdata = ProtectedData.Protect(sensitiveData, Nothing, DataProtectionScope.CurrentUser)
        MsgBox(pData.ToString)
    End Sub


    Private Sub Decrypt()
        Dim sensitiveData As Byte() = ProtectedData.Unprotect(pData, Nothing, DataProtectionScope.CurrentUser)
        Dim str As String = System.Text.Encoding.Unicode.GetString(sensitiveData)
        MsgBox(str)
    End Sub


You will of course need to add a reference to System.Security to your application and import the System.Security.Cryptography namespace into your code file.

The Side Effects of Debugging Code

The Side Effects of Debugging Code

David Kline makes a great point about the side effect of debugging code.  In particular, if you have properties that actually do more than simply returning a value, you can unexpectedly modify the state of the system just by exploring an object in the watch window. 


Visual Studio 2005 supports a number of attributes that can help control how objects are viewed during debugging:


DebuggerDisplay – This controls how the single line summary of the object is rendered when you hover your mouse over an object when in break mode.


DebuggerHidden – Can be used to attribute a method/property that you don’t want the debugger to step into when debugging.  Note that you can’t place a breakpoint in a method/property with this attribute, nor will this method/property appear in the call stack if you place a breakpoint further down the call stack.


DebuggerStepThrough – This marks code that will appear as “external” code when debugging.  Again you can’t place a breakpoint in this code.


DebuggerNonUserCode – Just when you thought there couldn’t be any more permutations on what will/will not be stepped through…. This attribute controls whether your code is stepped through when the “Just My Code” option is enabled (see Tools –> Options).


DebuggerTypeProxy – This attibute allows you to redirect the debugger data tip to display a substitute object in place of the object you are hovering over.  This can be great if you want to simplify the way your object is displayed during debugging.


DebuggerVisualizer – Use this attribute if you want a richer display for your object.  For example if you hover over a String object you will notice there is a magnifying glass in the data tip.  Clicking this brings up the String visualizer which is a window where you can view the entire string.  You can write your own visualizer by inheriting from the DialogDebuggerVisualizer class and then attributing your class with the DebuggerVisualizer attribute.


<Shameless plug>Samples of using these attributes is available in Professional Visual Studio 2005</Shameless plug>


 

Google cache to the rescue

Google cache to the rescue

In my previous post I mentioned the book review that was on Amazon but had subsequently been removed.  Anyhow Dave Gardner pointed me to Google cache (normal search with “cache:<url>” as the search string) and there it was.  So that we (Australians) can laugh at our perception elsewhere in the world, here is the review in full:


1 of 20 people found the following review helpful:


Worst book ever about .NET/Visual Studio, September 29, 2006





Reviewer: W. WEI “WW” (CA, USA) – See all my reviews
(REAL NAME)   
First, I did NOT buy this book, only came across it in a bookstore while trying to learn a few details about the new visual studio compilation system.

I guess every serious developer knows most Wrox books are junk, but still can’t believe they managed to publish such a stupid and worthless one.

It’s even worse than a simple rehash of the MSDN online documentation, which would at least save you some time to search through it.

The table of contents said it all: 56 chapters in 900 pages, most of which are made up of boring screenshots. Do the math and you’ll ask yourself the question: who are the targeted readers?

These 56 chapters covered every aspect of .NET: C#, VB, ASP.NET Web development, Windows Forms, Team System, Debugging, Macros, Refactor, Compact Framework…, in a very very very poor and shallow fashion.

So the next thing i did was to find out who were the authors, and there you are: two experienced/accomplished but “Australian” developers. In my albeit limited experience, the majority of Australian developers were shallow in their understanding of highly complexy technical stuff, and they write code in an exremely sloppy fashion. But these two guys are supposed to be the creme de la creme of .NET developers in that country, or maybe not?

In any case, next time you buy a book make sure where the author(s) are from first.