Sunday, December 5, 2010

MS Tech ED 2010 Day 4, Friday November 12, 2010

Today only 2 sessions (out of 3), because we have to leave early.

Architecture in Agile Projects – How to do it right

Speaker: Mitch Lacey (www.mitchlacey.com)
Link: http://www.msteched.com/2010/Europe/ARC208
Timeslot: 09:00-10:00

Notes:

  • Don’t expect that software will be right the first time. Accept that and write throw away code, just to learn. Create a working solution as quickly as possible. That’s when the light goes to green for the first time. After that refactor the code in order to complete new tasks (user stories), but always keep the bar green.

Light up on Windows 7 with WPF and Silverlight

Speaker: Pete Brown (http://10rem.net) pete.brown@microsoft.com
Link: http://www.msteched.com/2010/Europe/DEV308
Timeslot: 10:30-11:30

Notes:

  • This presentation was all about possibilities with the new Windows 7 API
    • System.Device.Location API access to GPS devices
    • http://code.msdn.microsoft.com/WindowsAPICodePack
    • Demo: Out of browser with Silverlight
    • Use dynamic for accessing IDispatch objects
    • Automation: Automate Excel
    • Location API: For connecting GPS and other kind of location sensors
    • Icon Overlay at the taskbar icon (automatically fading in/out)
    • Taskbar buttons at the button of the preview dialog (buttons can trigger an ICommand or event) TaskbarItemInfo.ThumbButtonInfos.
    • Progress bar overlay for the taskbar icon
    • Jumplist: Not specific to an instance of the application but to all. Defined in App.Xaml or App.Xaml.cs
    • WpfAccelerometer: About $30. Brand Freescale
  • All in all a very nice closing session and worth viewing.

MS Tech ED 2010 Day 3, Thursday November 11, 2010

Giving your Windows Phone XNA Games Plenty of Whizz and Bang

Speaker: Rob Miles (www.robmiles.com)
Link: http://www.msteched.com/2010/Europe/WPH310
Timeslot: 09:00-10:00

Notes:

  • Very entertaining and informative session. Watch the video for lots of information about Windows Phone Development and a good laugh.

The Future of parallel programming in Visual Studio

Speaker: Drew Robbins
Link: http://www.msteched.com/2010/Europe/DEV208
Timeslot: 10:30-11:30

Notes:

  • Current (available in .NET 4.0 for doing parallel programming):
    • Programming Models:
      • PLINQ,
      • Parallel loops
      • F#
    • Tools:
      • Concurrency Profiler
      • Debug
        • Parallel Tasks window
        • Parallel Stacks window
  • Future (available in .NET 5):
    • Tools:
      • MPI/GPU Profiler
      • MPI Debugger
      • GPU Debugger
      • Parallel Watch
    • Programming Models:
    • Language:
      • “async” modifier
      • “await” operator
  • HTTP://msdn.microsoft.com/vstudio/async
  • DryadLINQ (Parallel LINQ on the cloud):
  • http://research.microsoft.com/en-us/projects/dryadLINQ/

Microsoft Silverlight Performance on Windows Phone 7

Speaker: Oren Nachman (www.nachmore.com/blogs.msdn.com/oren)
Link: http://www.msteched.com/2010/Europe/WPH311
Timeslot: 12:00-13:00

Notes:

  • At least 2 threads in SilverLight
    • UI Thread
    • Compositer Thread (Phone specific)
    • User Threads
  • Debug Tools:
    • Counters
    • Redraw Regions
    • Calculate Fill Rate
  • CacheMode = new BitmapCache();

Managed Extensibility Framework in Action

Speaker: Dino Esposito (dino.esposito@crionet.it)
Link: http://www.msteched.com/2010/Europe/DEV402
Timeslot: 14:30-15:30

Notes:

  • MEF:
    • A special IoC framework available right within the .NET FX 4.0
    • Component based
    • Does IoC, but has different goals
    • and IoC overlap, but are different
  • Imports are automatically
  • Overlap: Injecting code into classes

Software Testing with Visual Studio 2010: Making it Real for YOU

Speaker: Brian Keller
Link: n.a.
Timeslot: 16:30-17:30

Notes:

  • Discussion session about VS 2010 capabilities for software testing.
  • VS 2010 Ultimate supports a record mechanism for automated UI testing.
    • References UI elements by their name (if possible), not their clicked mouse positions.
    • Replay is default as fast as possible, but can be slown down by inserting special commands.

Agile Estimation

Speaker: Stephen Forte (Telerik)
Link: http://www.msteched.com/2010/Europe/DPR201
Timeslot: 18:00-19:00

Notes:

MS Tech ED 2010 Day 2, Wednesday November 10, 2010

Yesterday I found out that Microsoft focusses on “the Cloud”. I want to know more about it. Especially how a private cloud could be created and if it would be of benefit for our customers.

The public cloud is especially usefull in case where a solution must be very scalable, like the website of an event (i.e. Tech ED). This is due to Microsoft’s pricing strategy.

Private Cloud Reference Architectures with Hyper-V and System Center

Speaker: Arno Mihm/Bryon Surace/Scott Rosenbloom 
Link: http://www.msteched.com/2010/Europe/VIR201
Timeslot: 09:00-10:00

Notes:

  • Software as a Service
  • Platform as a Service
  • Infrastructure as a Service (Today)
  • Private cloud hosted by a third party is possible also with a Hyper-V Cloud Service Providers
  • 6 different Service Partners (i.e. HP, Dell, etc.)
  • Private Cloud Management stack hardware should be redundant

WCF and Windows Server AppFabric - Services Made Easy

Speaker: Jon Flanders 
Link: http://www.msteched.com/2010/Europe/ASI304
Timeslot: 10:30-11:30

Windows Server AppFabric is a set of integrated technologies that make it easier to build, scale and manage Web and composite applications that run on IIS.

More info on the two Microsoft products named AppFabric: http://en.wikipedia.org/wiki/AppFabric

Building Windows Phone Games with Microsoft XNA and Visual Studio 2010

Speaker: Rob Miles (www.robmiles.com/)
Link: http://www.msteched.com/2010/Europe/WPH307
Timeslot: 12:00-13:00

One of the most interesting sessions IMHO. Worthily to watch the presentation.

  • Silverlight 3D is 2.5D
  • Appeared with SL 3.0
  • Now with GPU acceleration
  • Source code of all demo’s is available trough Rob’s own site

Windows Azure Boot Camp, Part 2

Speaker: Brian Prince
Link: n.a.
Timeslot: 14:30-15:30

Microsoft RemoteFX – What is it?

Speaker: Max Hermann/Rob Williams
Link: n.a.
Timeslot: 16:00-17:00

RemoteFX is a technology for making rich media applications capable to run realtime from a MS Windows Server 2008 R2 SP1/Microsoft Hyper-V 2008 R2 SP1. Basically it will sent compressed bitmaps of changed rectangles on the screen.

In order to do this, one needs a special ATI/nVidia graphics card that has a RemoteFX logo. This physical GPU will split it’s GPU into virtual GPU slices. Virtual GPU’s will use such slices. These specifications of those slices can be configured, so that a specific user can get more/less FPS and/or bandwidth.

One advantage from this technique is that very thin clients are now possible, needing nothing more than a monitor, keyboard and mouse attached. Vendors already have devices no larger than a couple of inches that can be mounted on the back of a LCD monitor. The size depends on the needed connecters (DVI, USB, etc).

A great deal of effort has been put in support for USB devices. It’s now possible to connect (at least one) USB device (i.e. phone or multifunctional printer). The thin client does not need to have a driver for this device. A generic USB driver at the thin client routes this device to the (virtual) RemoteFX OS.

Unfortunatly this technique will not be available between clients for remote support scenario’s

Architecting Applications for High Scalability – Leveraging the Windows Azure Platform

Speaker: Eugenio Pace
Link: http://www.msteched.com/2010/Europe/ARC309
Timeslot: 17:30-18:30

Notes:

  • Tailspin is a Software as a Service provider creating Surveys as a Service.
  • Command Query Responsibility Seperation (CQRS) pattern
  • Used many times in highly scalable systems
  • Create many tasks/roles and put them in a single workerrole. This is because you pay per workerrole.
  • http://msdn.microsoft.com/practices

MS Tech ED 2010 Day 1, Tuesday November 9, 2010

Getting your Return on Investment with Microsoft .NET Framework 4.0

Speaker: Drew Robbins
Link: http://www.msteched.com/2010/Europe/DEV201
Timeslot: 09:00-10:00

Notes:

  • It’s possible to run .NET 4.0 side-by-side with older .NET frameworks. It’s also possible to install VS 2010 side-by-side with older Visual Studio versions.
  • With an application manifest file it’s possible to force existing .NET applications to use the new .NET Framework 4.0
  • Starting with the .NET Framework version 4, you can use in-process side-by-side hosting to run multiple versions of the common language runtime (CLR) in a single process. By default, managed COM components run with the .NET Framework version they were built with, regardless of the .NET Framework version that is loaded for the process.
  • Install Visual Studio 2010 trough the new Web Platform Installer: http://www.microsoft.com/web/ 
  • The .NET 4.0 Client profile has been reduced in download size:
    • 28 MB for x86 platform only
    • 41 MB for x86+X64 platforms
  • A new Enterprise Framework (version 4.0): http://msdn.microsoft.com/en-us/data/ef.aspx
  • Introduction of Managed Extensibility Framework (MEF)

Building Data Visualization Applications with WPF & Silverlight

Speaker: Tim Huckaby
Link: http://www.msteched.com/2010/Europe/WCL321
Timeslot: 10:30-11:30

Notes:

Seen a few interesting demos showing the power of WPF/SilverLight and the Microsoft Surface device:

Windows Azure Boot Camp, Part 1

Speaker: Brian Prince
Link: n.a.
Timeslot: 12:00-13:00

Notes:

  • If anyone wants to give a Windows Azure Boot Camp within his/her own company, take a look at: www.windowsazurebootcamp.com. The Windows Azure Boot Camp team is helpful in supplying training material and free hours on “the cloud” for training purposes.
  • The GreyBox application is designed to alert a user if their Windows Azure compute services are currently running, or are even simply deployed. Great for Azure speakers and POCs you don't want left running: http://greybox.codeplex.com

The Total Noob’s Guide Windows Workflow Foundation 4

Speaker: Max Knorr (http://www.knor.net)
Link: http://www.msteched.com/2010/Europe/DEV211
Timeslot: 14:30-15:30

Notes:

  • WF basically is a visual programming language.
  • Activity can be seen as a control
  • Activity consists of “work to be done” and data.
  • Learned something new along this demonstration about code-snippets with CTRL K,X in Visual Studio: http://saraford.net/2007/12/10/did-you-know-ctrlk-ctrlx-inserts-a-code-snippet-103/
  • Different kind of activities
    • CodeActivity
    • AsyncCodeActivity
    • NativeActivity
    • DynamicActivity
    • CodeActivity<TResult>
    • AsyncCodeActivity<TResult>
    • NativeActivity<TResult>
    • DynamicActivity<TResult>
  • Windows Workflow foundation can be hosted in AppFabric (which in turn is build on IIS 7).

Tips & Tricks: Visual Studio 2010 IDE & Extensions

Speaker: Chris Dias
Link: http://www.msteched.com/2010/Europe/DEV302
Timeslot: 16:30-17:30

Notes:

10 Things Every New Silverlight and WPF Developer Must Know

Speaker: Pete Brown
Link: http://www.msteched.com/2010/Europe/DEV205
Timeslot: 18:00-19:00

Notes:

  • Very little new stuff for me as a experienced WPF developer.

Tuesday, February 16, 2010

Using batchfile to setup environment for running .NET Process

Today I faced a problem that I wanted to use a third party library, which depends on all kind of environment settings. Since this library came with an accompanying batch file for setting up this environment, I would like to reuse this batch file. After much googling I could not find a satisfying solution for my problem and decided to go for my own. The resulting code is here

// Run 3 commands in a "batch":
// setenv.bat: this will correctly setup the environment
// CLS: Ths will clear the screen (effectively sends a formfeed (\f) to the StandardOutput stream)
// SET: This will display the current environment variables (or send it to standard output
var processStartInfo = new ProcessStartInfo("cmd.exe")
{
Arguments = string.Format("/c {0} && CLS && SET", pathSetEnv),
RedirectStandardOutput = true,
CreateNoWindow = true,
UseShellExecute = false,
};
var process = Process.Start(processStartInfo);

// Wait until all commands have been processed
process.WaitForExit();

// Grab standard output
var standardOutput = process.StandardOutput.ReadToEnd();

// Grab all lines since last formfeed
var lastFormFeedIndex = standardOutput.LastIndexOf('\f');
var environmentSettings = standardOutput.Substring(
lastFormFeedIndex).Split(new [] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries);

// Adjust the current Environment Variables with the ones grabbed
foreach (var environmentSetting in environmentSettings)
{
SetEnvironmentVar(environmentSetting);
}


With the following helper for setting the environment:



[DllImport("msvcrt.dll")]
public static extern int _putenv(string varName);

private static void SetEnvironmentVar(string environmentSetting)
{
// We can not use Environment.SetEnvironmentVariable(variable, value);
// The problem relates to an unbalanced environment string encoding (ANSI/UNICODE).
//
// To prevent such errors, pair the getenv() call with a _putenv call to set
// the environment variables in C#. When using SetEnvironmentVariable() (from
// Kernel32.dll) pair it with a GetEnvironmentVariable in C++ and match your
// string encodings.
//
// So what uou need to do is replace your SetEnvironmentVariable call with ...
// [DllImport( "msvcrt.dll")]
// public static extern int _putenv( string varName);

// Environment.SetEnvironmentVariable(variable, value);
if (_putenv(environmentSetting) == -1)
{
throw new TcliWrapperException("Unable to set environment variable");
}
}

Monday, October 26, 2009

XamlParseException when no AssemblyInfo.cs file available

In my project I have an exe and a dll assembly. The App.xaml in the exe references a ResourceDictionary in the dll assembly. This had worked for a long time, but all of a sudden it stopped working. The following very frustating error showed up during runtime:

System.Windows.Markup.XamlParseException: Could not load file or assembly 'MyAssembly.MyResource, Version=0.0.0.0, Culture=neutral, PublicKeyToken=1cf5186c6493e5b0' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Error in markup file 'MyAssembly.MyResource;component/MyResource.xaml'. ---> System.IO.FileLoadException: Could not load file or assembly 'Pulsim.UnitConversions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=1cf5186c6493e5b0' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Strange thing is, that my compiled MyAssembly gets version 1.0.0.125.

So what this error basically says is: “I’m not able to load my self, because the version is incorrect.”

After several attempts to resolve this issue, I finally got to my build procedure which is based upon msbuild. I use CommunityTasks in combination with an automatic generation of AssemblyInfo.cs. This way makes it possible to include the SVN revision number in the assembly and file version. How to do that can be found here: http://rod.blogsome.com/2008/02/21/compiling-solution-in-visual-studio-with-generating-project-version-based-on-svn-revision/.

That article states that the following addition (among others) must be made to the .csproj file.

   1: … cut …
   2: <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   3: <Import Project="$(RootPath)\Common.proj" />

I finally switched line 2 and 3 in order to get the AssemblyInfo.cs file generated before the XAML parser/compiler kicks in. And guess what: it worked!

Summary: Be sure that an AssemblyInfo.cs file exists and is referenced within your project if you want to use XAML ResourceDictionaries!

Monday, July 13, 2009

Why are my WPF MenuItems grayed out

Well not all of them, but only those bound to WPF Commands.

After a 2 hour search, I finally found that a control that had focus, became invisible because it was not necessary anymore. Upon that event, my menuitems became grayed out (IsEnabled became false). Focussing a visible control on the screen resolved my issue.

So it seems that WPF Commands can not be executed when no focussed control is available.

Thursday, May 28, 2009

Databinding and LostFocus (HOWTO Force SourceUpdate for any WPF FrameworkElement)

Today I faced a bug that was not so easy to handle. While editing a value within a WPF textbox I pressed CTRL+S to save my work. Unfortunately my edited data was not saved, but the previous data was instead. How did that happen.

Well my WPF textbox was data bound to my dataobject. The dataobject (source) normally gets updated upon a Lostfocus of the textbox (that’s the default). However pressing CTRL+S (or even selecting the save menuitem under the file menu) does not result in the textbox losing focus.

OK. The short way to handle this problem is to get the binding expression of the textbox on de Text Property. Upon this binding expression it’s possible to call UpdateSource() explicitly and the value gets stored in the bound dataobject.

However I searched for a more generic approach because I do not have textboxes only. And it’s not always the Text Property that is being bound. So searching on the internet, I found a reaction on Nigel Spencer's blog: http://blog.spencen.com/2008/05/02/how-to-get-a-list-of-bindings-in-wpf.aspx#comment-1015806[^].

I modified the code a little bit to fit my needs and here is the result:

using System; 
using System.Windows;
using System.Windows.Data;
namespace MyNamespace
{
internal static class WPFHelper
{
internal static void ActionAllBindings(FrameworkElement targetElement, Action<BindingExpression> action)
{
WalkElementTree(targetElement, action);
}

private static void WalkElementTree(object obj, Action<BindingExpression> action)
{
var dependencyObject
= obj as FrameworkElement;
// Sometimes leaf nodes aren’t DependencyObjects (e.g. strings)
if (dependencyObject == null)
{
return;
}

// Recursive call for each logical child
ActionBindings(dependencyObject, action);
foreach (var child in LogicalTreeHelper.GetChildren(dependencyObject))
{
WalkElementTree(child, action);
}
}

private static void ActionBindings(DependencyObject target, Action<BindingExpression> action)
{
var localValueEnumerator
= target.GetLocalValueEnumerator();
while (localValueEnumerator.MoveNext())
{
var current
= localValueEnumerator.Current;
var binding
= BindingOperations.GetBindingExpression(target, current.Property);
if (binding != null)
{
action(binding);
}
}
}
}
}


Using the helper is extremely simple:



public void ForceSourceUpdateActiveElement()    
{
var focusedElement
= Keyboard.FocusedElement as FrameworkElement;
if (focusedElement != null)
{
MyNamespace.ActionAllBindings(focusedElement, bindingExpression
=> bindingExpression.UpdateSource());
}
}

Friday, January 25, 2008

IList is not serializable in combination with XmlSerializer

Because IList<T> does not implement ICollection (but the generic ICollection<T> instead), the XMLSerializer is not able to serialize the items within the collection. More info on this "bug" can be found here:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105767

Friday, January 4, 2008

Implementing a custom Dispose for a form or usercontrol

Have you ever wanted to implement a custom dispose method for a usercontrol or a form. Trying to override protected void dispose(bool disposing) learns that the designer generated file (mycontrol.designer.cs) already implements this override.

Mark Seemann wrote an intersting approach for dealing with this situation in his blog. It makes use of an Disposer component. A new instance will be created with a reference to a method implementing the custom dispose functionality. This instance is being added to the components collection. When the components get disposed, the this Disposer calls the delegate function with custom dispose logic. That's it.

Thanks Mark for this article.

Wednesday, August 15, 2007

Error: Validation of viewstate MAC failed. in ASP.NET page

Full error:

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the
same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.


This error may occur when one hosts an ASP.NET webpage on a web-garden.

Simple solution (for ASP.NET 2.0 and up): Generate a new machinekey and add it to the web.config.

Full explanation can be found in the blog of Jody.

Friday, June 8, 2007

Programmatic databinding between classes and controls

It's possible to programmatically databind to controls with the following statement:

myLabel.DataBindings.Add("Text", myObject, "Name");

However there are some specific controls that have trouble using databinding. Some should use another property, like Value or SelectedItem, while others need a specific
DataSourceUpdateMode. From my experience here's a list of controls and possible databindings:

  • Label
    myLabel.DataBindings.Add("Text", myObject, "Name");
  • TextBox
    myLabel.DataBindings.Add("Text", myObject, "Name");
  • NumericUpDown
    myNumericUpDown.DataBindings.Add("Text", myObject, "Age");
  • ComboBox
    mycomboBox.DataBindings.Add("SelectedItem", myObject, "Option", false, DataSourceUpdateMode.OnPropertyChanged);

Wednesday, May 16, 2007

Help not always on top!

Today I was asked whether it was possible to show the help in a non-modal manner. After a little searching on the internet, I found the following solution, posted in a forum by Rodger Constandse. It's a little trick but it works faboulous:

Create a new Form (once for an application). Call CreateControl() on it in order to create a handle to it, but it will not show up. See the following code-example:

public class MyApp
{
// Create a form as the parent for the Help window.
private Form m_HelpFormParent = new Form();

public MyApp()
{
// Enforce creation of a handle to the form
m_HelpFormParent.CreateControl();
}

public ShowHelp(string url, HelpNavigator command, object parameter)
{
// Call ShowHelp with the form created for this purpose as parent
Help.ShowHelp(HelpFormParent, url , command , parameter );
}
}

Sunday, April 22, 2007

Issue tracking with Gemini

In this blog I would like to mention some tools that I'm using, and that have helped me a lot. One of them is Gemini. We did issue tracking before with an Excel spreadsheet. But with growing number of team members that needed (simultanious) access to the issues, the spreadsheet way of working began to create a countereffect ...

After some searching on the internet I found Gemini (2.0.5 at the time), whose features look very attracting. Among the latetst version (2.1.1.) the following feature are available:

  • ASP.NET (2.0) web application running on IIS (v5, v6 or v7)
  • SQL Server database back-end (SQL Server 7, 2000, 2005 or MSDE)
  • Time-tracking (when you really want to ...)
  • Source control integration (Visual SourceSafe works perfectly, CVSNT integration and SubVersion adapter are available also)
  • Configurable email alert templates
  • Custom fields support (i.e. define additional fields for issues)
  • Personal issue filters (create your own view on the issue list trough a filter and save it the filter for later usage)
  • Gemini API – event/listener model (create your own extensions, we did not need them!)
  • Automatic project road map and change logs
  • Customisable issue type and priority (we extended the default types with ToBeTested)
  • Controlled anonymous user access
  • Flexible reporting – based upon XML/XSL
  • Export to Microsoft Excel
  • Issue linking across projects
  • Unicode support
  • Windows and web forms authentication (no need to log in when used on intranet)

One of the best things I liked was the ability to test with the free version for a reasonble amount of time (like forever) with a only few limitations. In the meanwhile our team has grown over the 10 user limit restriction and we have bought the product since it serves it's purpose very well. And that for only € 440, which gives you the abaility to use Gemini with unlimited users and on an internet-facing server!

These features combined with the financial aspect, convinced me to give it a try. Therefore I grabbed an old machine with a clean Windows XP installation. The machine specifications where not typically high end, with it's Intel Pentium III running at 800 MHz and 512 MB of RAM. Only installing takes a lot of time, but using the Gemini application has no noticable delays running on this hardware!

How to get up and running with Gemini on this machine (quickly may not be the right word, since 800 MHz is not lightning fast ...):

  • Install Windows XP, including IIS and with all the latest SP's and windows updates
  • Install Microsoft .NET Framework 2.0
  • Install SQL Server 2005 Express edition
  • Create a dedicated user account for Gemini which is allowed access to Gemini database within SQL Server.
  • Install Gemini
  • Adjust the web.config for customizing the following settings:
    - Database connection string
    - SMTP configuration
    - Set the Gemini URL, needed for emails being sent so that they implement the correct URL.
    - Set the DateFormat to EU
    - Set the authentication mode to Windows (instead of Forms) when using on an intranet.
    - Optional registration information

Additional (optional) steps:

  • In case you want to create the database and tables yourself, this is possible. See the documentation.Run IIS lockdown tool
  • Enable port 80 (HTTP WebServer) within the windows firewall.
  • Gemini supports Web Services Enhancements (WSE) 3.0. Certain web methods will require
    WSE to be installed on your web server in order to operate.

Last thing that I should really mention is the Gemini ScreenCapture application. This application allows a tester to quickly take a screenshot of the screen/window/user defined region and attach it to an existing issue. Before submitting it, the tester can something on the screenshot annotate with a pencil. This is really a cool feature that our testes use a lot.

Sunday, April 1, 2007

VSLive, Day 5, All about WPF

So, I'm very excited about Windows Presentation Foundation. Therefore I spent the last (workshop) day allday with Billy Hollis in his session about WPF, named: From the Ground up.

WPF is officially released. The tooling however to create i.e. XAML pages is in a very early state. The tools available at the time of writing can be found at the bottom of this page under resources. Therefore the amount of time it needs to write a WPF enabled application takes roughly 3 times longer than it should take, because of minimal tooling support. However it can still make sense to develop a WPF application, i.e. when the requirements of the app can be far more easily covered by an application using WPF.

Why is WPF such a revolution in UI design? The last transistion of the UI was 20 year ago. Every UI up until now was based upon GDI, invented in 1984. WPF is build on top of DirectX, which is capable of using all the power of graphic cards that are available to those stunning games also.

Furtermore it is vector based, making it possible to zoom without loss of detail.

In an attempt to fill in the gap between the rich UI experience on with Windows Forms on the web, a subset of WPF will be created by Microsoft, which is currently known as WPF/e (the e stands for everywhere). Some features are missing, like i.e. 3D. But WPF/e does not require .NET 3.0. It's even platform independent. It therefore supports MAC and Linux also. WPF/e will be introduced before the end of 2007. It will be a serious competitor for the nowadays widely used Flash.

User interfaces can be specified by XAML files (pronounced "Zammel"). XAML is an XML file, that describes the user interface as an hierarchy of (visual) elements. XAML is a big step towards declarative programming- Decalre what you want, not how it happens.

WPF Application Model:

  • System.Windows
  • Application objects as entry point
    - StartingUp, ShuttingDown events
    - Run method, MainWindow property, etc.
  • Visual elements
    - Page, Window

Sampleviewer (installed with "Visual Studio 2005 extensions for .NET Framework 3.0", currenlty a CTP) takes you around all the features of WPF one by one.

Differences between WPF and Windows Forms

  • No MDI in WPF
  • No build-in data grid in
  • WPF has "container/control" distinction
    - No Controls collection"Visible" > "Visiblity" in WPF
    - "Hidden" takes up space
    - "Collapsed" doesn't take up space
  • Absolute position in WPF is the exception, not the rule
  • Sizing and positioning are in device independent units (1/96 inch) in WPF
  • Scrolling is external to controls
    - ScrollViewer element
  • Non-containers can only hold one element
    - Called the controls "content"
    - Set with the Content property
  • Content can be any visual element
  • Content can itself be a container

Databinding:

  • Create a collection of stuff
  • Bind it to the context of the window
  • Bind controls to the item properties
  • Add navigation, filtering, sorting, and so forth

XAML Based Application (XBAP) are WPF enabled applications which can be used within a browser.

  • Act a lot like HTML pages
    - Non-installed, served from a web server
    - Browser hosted on the client (take over the whole browser surface)
    - Run in a security sandbox
  • Have their own project type under Visual Studio
    - Caution - March CTP bug on Vista
  • Published to Virtual Directory on web server
  • "NavigateURI" attributed used on links to navigate pages
  • App has read permissions to its original web directory
  • Can use IsolatedStorage for caching and state management.

Animation can consist of:

  • 2D and 3D Transforms
  • ...

Styles can be applied on the fly trough code or to triggers (i.e. hovering a button).

Ink is enabled in WPF (on Windows XP, after installing appropriate libaries).

3D Rendering of surfaces

  • Use full 3D capabilities underneath
  • Compose surfaces out of triangles
    - Triangle is the only primitive
    - Created as of MeshGeometry3D
  • Viewport3D is visual element to render 3D objects on screen in 2D
    - Apply camera angle, for example, to this viewport
  • Exporter for Autodesk 2DS Max is not (yet) official available

Types of events within the tree hierarchy of an WPF application

  • Direct (only on element)
  • Bubbling (move up the tree)
  • Tunneling events (from outside into the tree and down to the elements)

Tools for XAML:

Other resources:

Other blogs:

Examples of XAML Based Applications:

  • British Library, using WPF and thus requires Windows and .NET 3.0 installed at the client PC.

Saturday, March 31, 2007

VSLive, Day 4, .NET 3.0 & ASP.NET 2.0

More WPF today and a little bit on ASP.NET

WPF Keynote:

WPF = The best of the Web + The best of the desktop

Powerfull Graphics:

  • Scalable
  • Persisted, you draw something once and it stays on the screen.
  • 2D
  • 3D
  • Media
  • Animation

Next Generation Reading:

  • Pagination
  • Columnization (automatically and dynamically layout for best reader experience, seen new york time, seattle ...)
  • Cleartype
  • Rich content integration

Rich UI Framework

  • Databinding, but not the way we know it from pre-WPF times
  • Layout, trough panels
  • Controls, set of basic controls is available (free grid from XCeed)
  • Templates, The controls don't know what they look like, but ask the parent instead. If nothing specified then a default is being used.

Demo "Allscripts Patient Monitoring" shows WPF in Full power. It can be found at the PDC2005 page of Rob Relyea

"Power of Design, use design for better User Experience."

WPF is targetted to be used by 3 roles:

  • Developer
  • Designer
  • Integrator

http://www.notstatic.com/
http://www.loveyoursoftware.com/

-----------------------------------------------------

What can be animated:

  • Size
  • Position
  • Rotation
  • Color
  • ...

Why do you need animation? Animation fits the way the Human Brain works!

What technology should be chosen?

  • HTML: Online browser based, multiplatform, simple UI
  • WPF/e: Online browser based, multiplatform, (Flash alike) (small download, like Flash, targetted around 2 MB or so)
  • WPF in browser: Online browser, single platform, 3D etc. (requires .NET 3.0)
  • WPF locally: Installed locally with or without online capbilities (requires .NET 3.0)
  • Microsoft Blend (designer for XAML) visual design tool for designing UI.

WPF Examples WPF Application Portofolio

Datatemplate is a piece of XAML (segments) that describes how te represent the data. Switching at runtime of datatemplate is possible!!!

Demo cancer application: www.interknowlogy.com

Demo (from Microsoft site):
ExpenseIT, WPF/e demo, extension is .xbap

Demo
Evolution Media Center

Demo
UniveRSS A cool Reader!

Best reference book at the moment:
WPF Unleashed

Windows forms is at it's end-of-life. It will not being taken very further more.
WPF is in the early stages and will be primarly focussed by Microsoft to improve.

On BIG teams a dedicated developer for creating designs.

Some answers to questions from the audience:

  • XNA for gaming.
  • Deploying WPF is simple, the problem is the integrated video card.
  • XPS is killer for PDF.

-----------------------------------------------------

ASP.Live track: Building a Custom Membership and Role Provider

It's posible to use all the standard ASP.NET controls for login, loginstatus and so forth by implementing your own Custom Membership Provider. By also implementing a Custom Role Provider even the ASP.NET Web Site Administration tool works for managing users and roles.

By default ASPNET.MDF contains the user info. However what to do if you already have a database with user and/or role info. The following figure shows that the Proider Model allows you to replace an existing default provider with your own one in order to accomplish this:


Source: Building a Custom Membership and Role Provider, presented by Chris Franz at VSLive

Override every single method. The following methods are most important:

  • ValidateUser
  • CheckPassword
  • GetUser
  • CreateUser

All "MemberShip Provider Properties" must be overriden.

What about Password protection:

  • Hashed is most secure, other options are Encrypted or Clear.
  • Use Password SALT (this attaches a known string to the password, before encryption and therefore increasing the password length to a fixed length)
  • It requires a Machine Key within the Web.Config. This can not be autogenerated, because of webfarms where each machine needs the same key ...

4GuysFromRolla has a very good book about customizing the Membership with additional information for the user (like address, telephone, ...)

Role Provider Properties and Methods needs to be implemented (more needs to be implemented as with Membership Provider, but not all)

Web.config can exists per directory!

Microsoft provides an example provider: Introduction to the Provider Model on MSDN

Writing a Custom Membership Provider for the Login Control in ASP.NET 2.0, by Dina Fleet Berry

--------------------------------------------------------------

Plain Old Windows Forms tricks:

The tricks being presented by
Billy Hollis were:

  • Tooltips containing custom drawing including images
  • Implementing dynamic resizing without 1 line of code, by using the TableLayoutPanel and FlowLayoutPanel
  • Oval buttons
  • A tutorial form within a grid, trough the controls collection that every control (including grid) has.
  • Field-level security with one line of code.
  • Checking for unsaved data with 2 lines of code, through the DirtyChecker

All examples and sheets will be made available trough www.dotnetmasters.com/VSLifeSF.htm.

Tuesday, March 27, 2007

VSLive, Day 3, .NET 3.0

Some tools that make life easier for editting XML and XSLT
XMLEditor integrated into Visual Studio
  • Create dataschema from example XML
  • Associate schema to XML file enables template insertion of xml fragments

XSLT Debugger

  • Use breakpoints in the XSLT and watch variables.
  • Use breakpoints in the source XML file also.
  • Step into XSLT debugging from a normal code.

Future XSD Designer (availble within "Orcas")
Features including:

  • XML Schema Explorer
  • Entity Data Model (EDM) Wizard:
    Generates class model from existing database
    Drag and drop fields onto a windows form
  • Future EDM Designer:
    This is really cool stuff!!!
    Drag and drop database table onto the Entity Modeler.
    Drag another table over the first and the object combines the related tables into one object.
    Refactor database, while the objectmodel stays intact.
    Is going to work with ADO.NET
    New query language (Entity SQL)
    New Provider (Entity Client)

Data Interaction - LINQ to Entities

  • Query is an database language independent part of the code syntax instead of a database dependent string. It is being checked at compiletime.

Service Oriented Architectur (SOA) Design Patterns with Windows Communication Foundation (WCF)
When metadata is turned on then the WSDL. The URL of WSDL ends typically with <
url>?WSDL. This returns the top document that has a hierarchy of other WSDL documents describing each method or property on the interface. These can be viewed trough url?WSDL=, where reference can be found within the root WSDL.

Next to the WSDL an XSD schema is available also.

It's possible to extend (not change) the contract with an amendent. When a client uses an older proxy then the current service implements the response object has a filled ExtensionData element where the amendent can be found.

Breaking changes should be created within a new namespace. Nothing new here ...

Windows Presentation Foundation (WPF)
All possibilities from gaming engines made available within the .NET Framework.

WPF can call on GPU tools:

  • Transforms
  • Rotate
  • Scale
  • Gradients

Handles for windows nog longer exists. WPF renders controls within the main WPF window, which is the only window.

Since I have some experience with OpenSceneGraph, which is an excellent engine for 3D visualisation, I automatically compare WPF with the OSG. XAML is a declarative way of describing a scene, in some way this can be compared to a "scene graph" stored in an .OSG file. XAML however has the advantage that it can be verified against a scheme. I do not know whether both can be fully compared and hope to find that out within the next couple of days.

WPF uses style (wich can be compared to stateset in OSG???). Templates are more powerfull styles.

WPF uses scRGB values. -scRGB(0.5, 0.75,1.0).

Windows Communication Foundation (WCF)
Use Patterns & Practices for setting up Windows Communication Foundation. Visual Studio integrated CTP does a bad job for any more complex than very simple configurations.

WCF can be used for any layer (or better tier) that you want to implement for your solution. WCF can be scaled up (network boundary) or down (appdomain cross) later on, i.e. by implementing another protocol.

WCF Gives you:

  • Hosting
  • Instance Management
  • Asynchronious calls
  • Reliability
  • Transaction Management
  • Disconnected Queued Calls (i.e. trough MSMQ)
  • Security
  • An extensibility model for customizing nearly every aspect of its behavior.
  • Easy Interoperability (i.e. with Java by using basicHttpBinding, and JAX see ...)

Directly addresses .ASMX (and general Web Service) deficiencies:

  • Performance
  • Security
  • Transactions

So use WCF instead of .NET Remoting or .ASMX Web Services. These last 2 are deprecated. WCF fully replaces them, and offers a lot of other options more.

VSLive, Day 2, .NET Day

Today various speakers held several presentations and demos. This post summarizes the interesting things I heard today over all these presentations.

Visual Studio next generations
Codename "Orcas". CTP has been launched in March 2007. RTM is scheduled for late 2007.
Codename "Rosario". Will build further upon Orcas, featuring even more Team productivity trough their Team System.

WPF Demos that Rocks
Fabrikam. A virtual webseller of clothing, an example that uses SharePoint Server and WPF. Can not find it on the internet.
Family explorer by Vertigo. Will be made public by the end of this week.
WPFWonderland is all about WPF and WPFe

Vista compatibillity
User Account Control (UAC) is a new feature (note that a feature is not always an improvement) that influence applications running on Windows Vista. UAC is responsible for blocking access to functionality that requires admin priviliges.


When a user (even with local admin rights) starts an application, it will normally start without the admin privilige.

There are two ways to deal with admin tasks within an application:

  • Use a manifest that specifies that an application needs the admin privilige.
    This results in an application that upon starting notifies the user that the priviliges are being elevated to the admin level.
  • Elevate privilige "just in time" to the admin privilige within a running application, that started with normal privilige.
VSTO Rocks!
Visual Studio Tools for Office is an SDK that enables you to write fully blown Add-Ins for all office applications. This enables you to combine the power of .NET custom applications that are fully integrated into i.e. Excel or Powerpoint. With a few lines of code it's possible to add items to a custom ribbon. These add-ins can be document based or application based.

The document and Add-In can exist locally on the PC or somewhere remotely on the network.
3 scenario's for these customizations exist:

  • Local document, local Add-In
  • Local document, remote Add-In
  • Remote document, remote Add-In

One remark must be made that the full functionality of VSTO only works under VS 2005 Team System Edition. Some functionality will not work under VS 2005 Pro.

Database
Schema can be placed under source control trough the use of scripts. Every obejct within the database gets it's own script, like table, index and so on.

Developing a database project with Visual Studio looks very similar to devloping source code within a project. A live database can be imported and brought under source control. Check in and check out is very similar as with code. DBA Developers can change the database offline. When ready the DBA can review and update the live database.

Just renaming a field or so leads to "compile errors", because the field could be referenced. "Rename Refactoring" is capable of updating a field and all the places where it is referenced. This is very powerfull. This comes (optionally) with a "preview changes" dialog and it's also possible to use undo.

Database build, deployment and data generation can be integrated into MSBuild. Two types of deployments exist:

  • Full
  • Incremental
    This only deploys the difference between the target and the project.

Unit testing is now available, so you're existing code does not break upon changes.

PowerTools will be distrubuted trough the web. These include:

  • Move Schema Refactoring
  • Disambiguate Schema Refactoring
  • sp_rename Generation
  • Data & Schema Compare Build Tasks
  • SQL Script Pre-Processor
  • Dependency Tree Viewer
  • API Access to Schema View

ASP.NET
Brian Randall from MCWTech

"There is NO MAGIC to make your applications run faster"

Tools:

  • Process Explorer by Sysinternals, can be dragged over the application.
  • Process Monitor by Sysinternals.
  • Performance Monitor
  • Visual Web Developer 2005 Express Edition

    $$$
  • VS 2005 TE for Software Testers

    $$$$$
  • VS 2005 Team Test Load Agent

Tips:

  • Use Release Builds! If the release item is unavailable it could be that this option can be found in the web.config under the compilation tag.
  • Minimize Exceptions, because they are expensive.
  • Optimize Data Access.
    Avoid using unmanaged classic ADO. Use
    stored procedures for complex functionalities.
  • Design for Caching
    Output caching (caching a whole page hat has been requested)
    Fragment Caching (caching regions of a page)
    Cache API

Visual Studio Team Test lets you easily create repeatable tests, that can be adjusted to generate random requests to the ASP.NET page under test. These tests can be used within a load-test scenario. Performance counters help in determining where bottlenecks can be found.

Monday, March 26, 2007

VSLive, Day 1, Pre-Conference workshop (CSLA)

Build Distributed OO Apps in .NET 3.0

Speaker: Rockford Lhotka

Most important things heard today:


N-Tier is not the same as N-Layer.
N-Layer is always good, especially to structure your code, which makes it maitainable.
N-Tier involves a process-boundary, or even a network boundary. Therefore a tradeoff must be evaluated from the following:

  • Performance
  • Scalability
  • Fault tolerance
  • Security

Formula to calculate the Concurrent Transactions Per Second (ctps):
ctps = (NrOfUsers / UserThinkTime) * TransactionDuration

Split up Business Logic Layer in Client and Server.
In order to use business logic close to the UI for a rich UI feeling and close to the data layer for multi-object logic, one could split the business layer.

The splitted layer could be conneced using a DataPortal, which encapsulates the underlying mechanism (Remoting, WCF, Webservice, etc) of transfering the business objects from the client to the server and back. The DataPortal is an implementation of the Channel Adapter Design Pattern.

Using event and (binary) serialization.
Be careful with events and serialization, because you might serialize more than expected, depending on the serializer being used. Serializers that serialize (private) fields will also try to serialize the class that has an event subscription on the class, because it's referenced in the list of subscribers. 3 possibilities from here:

  • This is planned to happen.
  • This is not planned, but the subscriber class is serializable. This results in a larger performance and/or memory footprint hit, then expected.
  • This is not planned and the subscriver class is not serializable. This will result in an exception being thrown.

Solution for preventing the subscriber class from being serialized is to implement your own implementation of AddHandler, RemoveHandler and RaiseHandler.

The CSLA Framework.

"Rockford Lhotka’s CSLA .NET framework is an application development framework that reduces the cost of building and maintaining applications.

The framework enables the use of object-oriented design as the basis for creating powerful applications. Business objects based on the framework support many advanced features to simplify the creation of Windows Forms, Web Forms and Web Services interfaces." (copied from CSLA website)

The CSLA Framework combines (when needed) the best of object orientation and databinding, by providing a set of base-classes for objects that already common functionality for implementing IBindable.

Als it provides a method for defining Validation and Authorization rules. One can add (static) methods that add rules to a rules collection. For Authhorization each getter, setter and method must start with an additional call to a generic validation method to determine whether the current user may access the getter/setter/method in question. For Validation the setter must add an additional call to a generic validation method. Important here is that a "bad value" must be accepted and no exception may be thrown. The databindable components or errorprovider must examine an object to determine whether it has valid values for each property.

This framework could really enforce a jumpstart when implementing an object oriented design, that needs to be coupled preferably by standard .NET databinding.

LINQ, Language Integrated Query.

LINQ is a Microsoft Project that adds a native quering syntax to .NET Framework programming languages, therfore reducing the roughly 20 lines of code needed to fetch data back to 3 lines.

Additional CSLA resources:

Friday, March 23, 2007

Hello world!

These are the famous words for an application written with a new technology (at least for the developer in question). And blogging is new to me.

So here's my blog.

I don't know whether I'm going to feed this a lot, but at least it gives me some space on the internet, where I can leave my toughts about software development.