Unity 2.0 update - comprehensive error reporting! Important in PRISM/DI environment.

by 7. August 2009 02:43

I keep my finger on the pulse of Microsoft's newest technologies and updates; I typically find that they make my life a lot easier by helping me to be more productive for my clients.   The latest Unity 2.0 updates did not disappoint!

On THIS LINK (image below) you'll find the following information on the Unity 2.0 update which is currently available for download in the http://www.codeplex.com/Unity downloads area:

Anyone having to troubleshoot an enterprise level application that uses dependency injection will appreciate the new power provided to us.  In my case I use the PRISM framework and have spent my fair share of time locating errors caused by a failure to register a dependency.

THIS WEBCAST shows that within a few minutes (literally) we can track down and resolve (no pun intended) an issue.


Running Crystal Reports from Silverlight

by 6. January 2009 15:05

I provide a short WebCast supplementing this blog - HERENote: It appears I was having some audio difficulty in the early part of the webcast showing how to navigate to the HTML BROWSER INTEGRATION webcast - since I provide the link below I published the webcast as is.

The following www.Silverlight.net webcast HTML BROWSER INTEGRATION provides the key to running Crystal Reports from Silverlight.  Once you complete the webcast you'll find it takes only a few steps to get your Crystal Reports up and running.

I downloaded the C# Source code from the above referenced link, added the following class (MyClass) to the HtmlInteraction_CS project's Page.xaml.cs file and updated the Button1_Click() to support it:

/// <summary>

/// Added Inner class for proof of concept

/// </summary>

public class MyClass


    public string ReportName { get; set; }

    public int ID { get; set; }


    /// <summary>

    /// Override ToString so we can easily return our

    /// URL Parameters

    /// </summary>

    /// <returns></returns>

    public override string ToString()


        return string.Format("?ID={0}&Name={1}", ID, ReportName);




/// <summary>


/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void Button1_Click(object sender, RoutedEventArgs e)


    // Instantiate class setting ReportName to textbox value

    MyClass para = new MyClass


        ID = 10,

        ReportName = TextBox1.Text


    // Invoke the sayGoodbye javascript method


        new string[] {para.ToString()});



With my Silverlight code completed I only needed to prepare the Website code.  I renamed the testpage to CrystalReportPrototype.aspx and added the window.open("Report.aspx"+fname, "_blank") to the sayGoodbye(fname) javascript method as shown below:


So all that remained was to create my Report.aspx and reports.  I dropped a CrystalReportViewer object on the page and named it Demo1.  I then parse out the "Name" and run the applicable report, i.e., DemoReport (default), DemoReport1 and DemoReport2.

After I saw all was well I used Expression Blend to spiffy up the Silverlight screen (took all of five minutes):


SL-HtmlInteraction.zip (1.68 mb)  <= SOURCE CODE


by 20. July 2008 07:41

With the overwhelming number of things to learn, and resources you have to sift through (to determine their value), I would have to say that the following Channel 9 webcast is a gem if you are starting to work with WPF.   XBAP for the most part is underdocumented - this reveals much of it and it should raise your interest as well as your understanding.


Imagine being able to share user controls between your Windows and Browser applications - the only differing component is the view and it's code behind (with the Presenter, controllers and model being shared by both platforms)....

While assisting jjalexrayer with his Load module in shell in WPF Browser Application issue I discovered that it is possible and practical to share controls between platforms with WPF.   Using the CompositeWPF Commanding solution I was able to reuse all of the business rules and logic in a browser application with minimal coding.  

I used the Commanding.sln and added a new WpfBrowserApp project (source code attached below).  The CommandingBootStrapper.cs file follows:

using System.ComponentModel;
using System.Windows;
using Commanding.Modules.Order;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.UnityExtensions;
using WpfBrowserApp;

namespace Commanding
    class CommandingBootstrapper : UnityBootstrapper
        Page1 shell = null;
        public CommandingBootstrapper(Page1 page)
            shell = page;

        protected override DependencyObject CreateShell()
            return shell;

        protected override IModuleEnumerator GetModuleEnumerator()
            return new StaticModuleEnumerator().AddModule(typeof(OrderModule));

Page1 Code behind looks as follows (didn't need the Container - just wanted to see if it would be there - it was :)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Practices.Unity;
using Commanding;

namespace WpfBrowserApp
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
        private IUnityContainer _container;
        public IUnityContainer Container
            set { _container = value; }

        public Page1()

            CommandingBootstrapper bootstrapper =
                new CommandingBootstrapper(this);


I grabbed the XAML from Command projects Shell (minus the Window.Background elements) so that the CommandingBootStrapper wouldn't puke - it needs the GlobalCommandsRegion and MainRegion.   I was pretty surprised to find the Page1 XBAP code ran exactly as the Shell WPF! 

<Page x:Class="WpfBrowserApp.Page1"
            <RowDefinition Height="50"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
        <StackPanel Grid.Row="1"  Margin="10,0,10,0">
            <ItemsControl cal:RegionManager.RegionName="GlobalCommandsRegion" />
        <Border Grid.Row="2" CornerRadius="4,4,4,4" BorderBrush="#193441" Background="#FCFFF5" BorderThickness="2,2,2,2" Margin="10,0,10,10" Padding="5">
                <ItemsControl cal:RegionManager.RegionName="MainRegion" />
        <Label HorizontalAlignment="Left" Margin="155,5,0,0" Width="Auto" Content="QuickStart" FontWeight="Normal" Foreground="#FF373737" FontSize="24" FontFamily="Corbel"/>
        <Label HorizontalAlignment="Left" Margin="10,5,0,0" Width="Auto" Content="Commanding" FontWeight="Bold" Foreground="#FF373737" FontSize="24" FontFamily="Corbel"/>
        <Separator Margin="0,0,0,0" VerticalAlignment="Bottom" Height="10" BorderBrush="#193441"/>

Walla!  I was reusing the WPF application's code in a browser application. 

Source code for WpfBrowserApp (above code) WpfBrowserApp.zip (313.91 kb)

Related Codeplex topic Can I develop XBAP application with this framework?


WPF - the next big adventure...

by 20. July 2008 06:45

In Adam Nathan's "Windows Presentation Foundation Unleashed" introduction, Adam shares with us that the learning curve for WPF is "very steep"; an excerpt follows:

Even viewing the source code for WPF (by cracking open its components with a tool like .NET Reflector) is a confusing experience because the code you’re looking for often doesn’t reside where you’d expect. When you combine all of this with the fact that there are often several ways to accomplish any task,you arrive at a conclusion shared by many: WPF has a very steep learning curve.

FORTUNATELY, Microsoft is helping us with free webcast to understand WPF and minimize this learning curve.  Important link follows:

http://msdnevents.com/live-webcasts.aspx - click on the WebCast link and type in WPF; you won't find all 18 webcast but they are there (they aren't caught in the filtered search).   I am on lesson 12 of 18 (each lesson is approximately an hour), which lead me to the above referenced book.  I plan to complete the webcast series and the book before attempting to dissect and understand the ComposteWPF.  Note: I created an Access database to index the content and it's location within each webcast, e.g., to locate Expression Blend tutorials such as an early one where Bill Steele rotates his plane (current index here: Index.mdb (588.00 kb) - it may only have meaning to me however I'll make it available as it is updated - just in case...)

The CompositeWPF (aka Prism) is where my introduction to WPF emerged - I downloaded one of the early Prism drops and was totally lost!  Even with my knowledge of MVP and the Object Builder I knew nothing of Dependency Injection.  After hours of research I started to grasp glimmers of understanding for the voodoo I was observing- which Glenn Block offered assistence with HERE.   Today, with much patience from folks like Chris Tavares (patience with my ignorant questions and statements) I see the light.  Unity rocks and I plan to write numerous blogs that will help others who have no experience with Dependency Injection, and worse yet - no knowledge of MVP understand its power.



Blog videos and references to CodePlex projects are no longer valid