SteveB at the Microsoft Developer Forum, Japan

Just a link to some interesting things that SteveB talked about at the recent developer forum in Japan;

I can’t find an online video of the session yet but the transcript is up here and has some interesting pointers around a few future areas.

Please note that I’m not attempting to add commentary or interpretation here, I’m just quoting the public press release and suggesting that it’s very worth reading.

Here’s some snippets – firstly around HTML and JavaScript;

“The third area that I think will be increasingly important is HTML and JavaScript. We've made a big investment, obviously, in Windows and IE9 in our HTML and JavaScript support, but more and more of the world's programmers will be fluent in these technologies in addition to whatever skills people have in C++ and C# and a variety of other important skills. But we have to recognize that more and more of the world's talent will know these techniques. And whether it's writing a website or a client application, or a server application, we want to build and develop the range of things that you can do not only using .NET, but also in using HTML and JavaScript. And, in fact, even how you can weave these things together into sensible programs in the future.”

and then around the move to ARM;

“Just think back three or four years ago and how quickly performance and size, and miniaturization and the move to ARM processors has happened. We've announced with Windows that we're going to support system-on-a-chip "architectures, not only from Intel and AMD, but also from a set of ARM vendors.”

and around Visual Studio;

“Today you write a program and as you're writing it you have to say, what computing resources does it use, how much of it runs on a client device? How much of it runs in the server? How is my server going to get set up and provisioned? How is my application going to get deployed? How do I deploy it in a redundant fashion, to have good business continuity, in the event of the kind of natural disaster that we saw here in Japan? As we are rebuilding Visual Studio, .NET, Windows Azure, we essentially are designing around the automation of program development and deployment, and the operation of those activities.”

and then around Windows;

“We're obviously hard at work on the next version of Windows. Windows 7 PCs will sell over 350 million units this year. We've done a lot in Windows 7 to improve customer satisfaction. We have a brand new user interface. We've added touch, and ink, and speech. And yet, as we look forward to the next generation of Windows systems, which will come out next year, there's a whole lot more coming. As we progress through the year, you ought to expect to hear a lot about Windows 8. Windows 8 slates, tablets, PCs, a variety of different form factors.

The browser is an area where we've been very active. Internet Explorer 9 is the fastest browser around because of the way that we've married it to Windows systems and allow essentially full exploitation of the hardware to have the fastest and most beautiful Web on the planet run on Windows systems.

We've integrated the browser into Windows more fully, so that you can put jumplists, and pin those to the taskbar on Windows. We've improved JavaScript performance. We're running on downloads that are about five times the rate of customer acceptance that we saw on IE8. and when it comes to HTML and JavaScript, and the browser, there will be simply no one who pushes that, not Google, not Firefox, nobody will push that faster and harder than we push with IE.”

and finally around developers Smile

“The relationship with developers is the most fundamental relationship between Microsoft and its customers. You're it. You write the programs, the applications that really turn on all of our customers to the power of information technology, whether you're writing for the phone or the Xbox, the PC, or the tablet, your work is the work of our industry. And our No. 1 goal in life is to support the developers, developers, developers here in Japan and across the world.”

Very interesting stuff – I’ll link to the video as/when I find it.

ClickOnce, TaskDialogs, Common Controls and WPF Applications

One of the things that I talked a little about in my talk about “Modern Windows Applications on Windows 7” was around the idea of using a TaskDialog when you’re trying to get a response from the user rather than using your own custom dialog or a MessageBox or similar.

As an aside, this isn’t just about TaskDialogs and MessageBoxes and so on – there’s other reasons why you would want to get the latest version of common controls loaded into a WPF application but this particular area was one that I’d left “hanging” at that previous talk as I hadn’t resolved it at the time.

TaskDialog isn’t represented in the .NET Framework at all as far as I know so you need to look to the Windows API Code Pack which provides a managed TaskDialog class that you can make use of to make getting to the native APIs pretty easy.

To illustrate this in its entirety, here’s the world’s simplest example.

image

and then I can put a nice button my app;

image

and if I add a reference to the right assembly from the code pack;

image

and write a little code;

      TaskDialog dialog = new TaskDialog()
      {
        Caption = "I'm a task dialog",
        InstructionText = "Not much to see here right now",
        StandardButtons = TaskDialogStandardButtons.Ok 
      };
      dialog.Show();

then it’s “all good”. Except it isn’t in that running the application won’t work. It hits an exception because of loading the wrong version of the common controls library so when you run it and try and raise the TaskDialog the code in the code pack is smart enough to realise that the particular entry point that it’s looking for in common controls isn’t there in the DLL and raise a nice .NET exception saying so. It looks a bit like this;

image

But “not to worry” because this is easily fixed by adding a new application manifest to the project (from the Add New Item dialog) and the default manifest file that Visual Studio inserts for you comes with a bit of XML that you can just uncomment;

  <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
   <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>

and then the application “works”;

image

until it comes time to try and publish it via ClickOnce. At that point, you descend into some error messages…

image

Now, I must admit that I spent quite a lot of time blocked by this error message. I tried lots of ways to work around it but ended up being pointed to this post which talks you through how to work around this manually.

However, even after I’d read that post I still wasn’t 100% sure about the exact steps to follow and so I thought I’d write up my own findings here. In doing that, I also ended up reading;

Remove the Manifest Just Added

The first thing to do is to undo the last step and remove the app.manifest that we added in Visual Studio from your project in order to return to the place where the project will build and publish via ClickOnce but will crash when you first trying and make use of TaskDialog because the wrong version of common controls is loaded.

Adding the Manifest to the Executable

Now, publish via the ClickOnce bits in Visual Studio. Then go to the folder that you’ve published into which will probably look something like this (for a vanilla, “hello world” style of application);

image

and within the “Application Files” folder there’s a version-specific folder that contains (in this simple case);

image

The first thing to do is to edit the executable in order to insert a resource containing a manifest that specifies V6 of common controls. I used this file;

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0"
                xmlns="urn:schemas-microsoft-com:asm.v1"
                xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
                xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="*"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        />
    </dependentAssembly>
  </dependency>
</asmv1:assembly>

which I saved to my desktop in notepad with a UTF-8 encoding. I then opened up the EXE file which in my case is MyTestApp.exe.deploy in Visual Studio’s binary resource editor. That is;

image

image

image

and then in the resource editor, add a new resource as in;

image

and then import a resource;

image

and import the file that you saved the manifest into giving it an identifier of RT_MANIFEST as in;

image

and then using the properties window to change its ID to 1 rather than 101;

image

and then save the file from Visual Studio.

Updating Signatures

The problem with what we’ve just done is that we’ve changed the executable and there’s a chain of signatures that we’ve just invalidated in the application manifest and then the deployment manifest.

The Application Manifest

Firstly, the application manifest file which in my case is MyTestApp.exe.manifest;

image

This needs fixing because it has a picture of the files that make up our application and that needs refreshing now that we’ve updated the main binary.

There’s more than one way of doing this but the route I took is to use the MageUI.exe tool.

The first thing to remember with this tool is it’s easier to use if you use the Preferences option to tell the tool which certificate you want to use for signing. If you just did a quick publish from Visual Studio then the certificate would have been generated by the environment for you and would be called _TemporaryKey.pfx so you could select that one as I’m doing here;

image

and then ( as long as you have “Sign on save” set ) then that certificate will be used when you save manifests from here.

Next, open up the equivalent of MyTestApp.exe.manifest in the tool;

image

and then we want it to rebuild its picture of the bits/bytes of the files that make up our deployment so go to the Files tab;

image

and remove the MyTestApp.exe.deploy by selecting the row and hitting DEL on it and then use the Populate button to re-populate the file list from the folder;

image

and in this case I have ended up with an extra MyTestApp.application.deploy sfile o I get rid of that file by hitting DEL again;

image

Now, save the file and it should have refreshed its picture of the MyTestApp.exe.deploy file and have signed the resulting manifest.

The Deployment Manifest

Next, open the deployment manifest which in my case would be called MyTestApp.application and resides 2 folders up from the application manifest.

image

We need to get this file to refresh it view of the application manifest that we just altered so go to the “Application Reference” tab and re-select the application manifest that is already selected;

image

and with that re-selected, save the file.

As an aside related to .NET 4.0, I find that when I’ve saved this file and I open it up in notepad then a required element called compatibleFrameworks seems to disappear. There are various references to this on the web and what I recommend is simply opening up the file again in notepad, adding a compatibleFrameworks element such as;

  <compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
    <framework targetVersion="4.0" profile="Client" supportedRuntime="4.0.30319" />
    <framework targetVersion="4.0" profile="Full" supportedRuntime="4.0.30319" />
  </compatibleFrameworks>

and then re-opening in mageui.exe and saving again to refresh the signature which (strangely) seems to leave the compatibleFrameworks element alone this second time.

With that done, you should be able to perform your ClickOnce deployment and have the TaskDialog display correctly on the screen Smile Here’s my “app” run from the start menu and doing the right thing;

image

That seems to work for me although it’s worth saying that I’ve only tested to deployment on Windows7 and you might have to tweak for Vista/XP.

The last thing I’ll say here is that you may well want to do this from a build rather than doing it manually with visual studio and I think that mage.exe as a command line tool can help you there and you can perhaps look to mt.exe in order to embed the manifest into the executable after it’s been built.

UK TechDays Virtual Client Conference–Resources

At the UK TechDays online conference last week there were a number of sessions around Silverlight and Windows that I wanted to provide follow-up resources on here.

Session: Modern Windows Applications

  1. Visit Develop For Windows
  2. Download the WPF Ribbon Control and get the information on it here
  3. Download the Windows API Code Pack
  4. Read more about the Code Pack
  5. Learn about the Task Bar with WPF 4 ( and part 2 )
  6. More on the Windows 7 TaskBar
  7. More on Windows 7 Libraries
  8. Windows 7 Sensors
  9. Restart/Recovery for Applications
  10. WindowChrome – altering the non-client area of the window.
  11. Subscribe to the Windows Team blog.

Session: User Interfaces with Touch

  1. Some recent local resources on touch;
    1. Touched ( Part 1 )–Getting Touch for Free
    2. Touched ( Part 2 )–Raw Touch Events
    3. Touched ( Part 3 )–Manipulation and Gesture Support
    4. Touched ( Part 4 )-Simple Example
    5. Touched ( Part 5 )–Touch-Ready Controls
  2. Read more about WPF 4 Multi-touch and more
  3. Check out the Native Extensions for Silverlight Preview 2

Session: Silverlight Platform Overview

  1. Visit Silverlight.Net
    1. Watch videos
    2. Try the QuickStarts
    3. Checkout hands-on labs
    4. Read books
    5. Read whitepapers
  2. Watch the Silverlight Firestarter
  3. Visit Channel 9
    1. Follow Silverlight TV
    2. Subscribe to the Silverlight tag
  4. Follow Silverlight Q&A on StackOverflow.
  5. Subscribe to the Silverlight Team blog.

Session: Buffers Guide to Expression Blend

  1. Visit Expression on the web.
  2. Learn Blend via tutorials, starter kits, etc.
  3. Check out the Toolbox resources
  4. Local resources on Blend;
    1. 20 recent posts on Blend
  5. Subscribe to the Expression Blend team blog.

Session: Silverlight for Line of Business Applications

  1. Refer back to the general section on Silverlight here.

Session: Silverlight and Multi-tier Applications

  1. Silverlight Networking Videos on Channel 9
  2. Visit the RIA Services Site
  3. Visit the OData site.
  4. WCF Data Services on MSDN.
  5. Understand the WCF subset in Silverlight.
  6. Understand the security options in Silverlight for service access.
  7. and again
  8. and again
  9. and again
  10. Understand the Client/Browser HTTP stacks in Silverlight

Session: WCF RIA Services

  1. Visit the RIA Services Site
  2. RIA Services on MSDN
  3. Watch Deepesh at TechEd 2010
  4. Subscribe to Deepesh’s blog.

Session: MVVM and RIA Services

  1. Watch John’s session from PDC 2010.
  2. Read Josh’s article on MVVM.
  3. Subscribe to John’s blog.
  4. Follow the RIA Services resources from the previous session.

Session: Silverlight Apps with PRISM

  1. PRISM on CodePlex
  2. PRISM on MSDN
  3. PRISM videos on Channel 9 ( previous PRISM version )
  4. Subscribe to Karl’s Blog

Session: Premium Media Experiences with Silverlight

  1. Learn about the Silverlight Media Framework.
    1. Watch videos on Silverlight.net
  2. Learn about IIS Media Services
  3. Subscribe to David’s blog.