Showing posts with label UnityApplicationBlock. Show all posts
Showing posts with label UnityApplicationBlock. Show all posts

Monday, April 21, 2014

Prism continues its Windows Desktop/WPF/MVVM Love with v5

Francis K. Cheung - Prism 5.0 for WPF just shipped.

Prism version 5.0 for WPF is now available. This version of Prism includes updates to existing and several new NuGet packages:

  1. Prism
  2. Prism.Composition (New)
  3. Prism.Interactivity (New)
  4. Prism.Mvvm (New)
  5. Prism.MefExtensions
  6. Prism.UnityExtensions

We’ve updated Prism 4.1 with bug fixes and a few new features. ...

Developer's Guide to Microsoft Prism Library 5.0 for WPF

April 2014

Prism provides guidance in the form of samples and documentation that help you easily design and build rich, flexible, and easily maintained Windows Presentation Foundation (WPF) desktop applications. Using design patterns that embody important architectural design principles, such as separation of concerns and loose coupling, Prism helps you to design and build applications using loosely coupled components that can evolve independently but which can be easily and seamlessly integrated into the overall application. In short, these applications are "built to last" and "built for change." These types of applications are known as composite applications.

This topic provides a brief overview of the Prism concepts with links to associated source code and documentation. If you are considering upgrading from Prism 4.1 to Prism 5.0 we include a "What’s New" and "Upgrading from Prism 4.1" topic that you should read.




What's New in Prism Library 5.0 for WPF

Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF, new and updated QuickStarts, and updated documentation. Parts of the Prism Library changed between Prism 4.1 and Prism 5.0 to support the new guidance, fix existing issues, and respond to community requests.


New Guidance

Prism 5.0 contains several areas of new guidance as follows:

  • Prism.Mvvm is a portable class library that encapsulates Prism’s MVVM support. This library includes ViewModelLocationProvider. Views and view models can be wired up together using the new ViewModelLocationProvider’s convention-based approach as explained in Implementing the MVVM Pattern. View model construction can be accomplished using a dependency injection container. The ViewModel Locator’s extensibility points are discussed in Extending the Prism Library. DelegateCommands are now extendable and provide Async support. A new implementation of the INotifyPropertyChanged interface, the BindabaleBase class, was added.
  • The PopupWindowAction class was added to the Prism.Interactivity assembly to open a custom window in response to an interaction request being raised.
    The InvokeCommandAction action provided by Prism now passes trigger parameters to the associated command.
    For more information see Advanced MVVM Scenarios.
  • The EventAggregator classes have been moved to the Prism.PubSubEvents portable class library.
  • The NavigationParameters class can now be used to pass object parameters during navigation, using the overloads of the RequestNavigate method of a Region or RegionManager instance.

Changes in the Prism Library

Prism Library 5.0 includes changes related to new functionality, code organization, and APIs.

Code Organization


API Changes


Additions to the Prism Library Core API

The following namespaces were added to the Prism Library to support the new areas of guidance added in Prism 5.0:

  • Microsoft.Practices.Prism.PubSubEvents was added to help you send loosely coupled message using a portable class library.
  • Microsoft.Practices.Prism.Mvvm was added to assist you in implementing MVVM using a portable class library and several platform specific libraries.
  • Microsoft.Practices.Prism.SharedInterfaces has been added to share the IActiveAware interface between Prism and Prism.Mvvm assemblies, therefore the IActiveAware interface has been moved to this assembly. It is also intended for future use.

CodePlex Issues Resolved

  • ...

Example Code Changes

Prism 5.0 contains eleven separate code samples that demonstrate portions of the provided guidance. Several samples from Prism 4.1 were removed or replaced, and new samples added.

The following samples were added for Prism 5.0:

  • Basic MVVM QuickStart. This QuickStart shows a very simple MVVM application that uses the ViewModel Locator and show a parent and child ViewModels. For more information, see the MVVM QuickStart.
  • MVVM QuickStart. This QuickStart was removed for this version.
  • MVVM Reference Implementation. This reference implementation was removed for this version.
  • View-Switching Navigation QuickStart. This QuickStart now supports WPF. It demonstrates how to use the Prism region navigation API. For more information, see View-Switching Navigation QuickStart.
  • State-Based Navigation QuickStart. This QuickStart now supports WPF. It shows an approach that uses the Visual State Manager to define the views (states) and the allowed transitions. For more information, see State-Based Navigation QuickStart.
  • UI Composition QuickStart. This QuickStart now supports WPF. It replaced the View Injection QuickStart and the View Discovery QuickStart from Prism 2.0. In the current versions, both concepts are shown in one example application. For more information, see UI Composition QuickStart.
  • Interactivity QuickStart. This new QuickStart demonstrates how to exposes an interaction request to the view through the view model. The interactions can be a popup, confirmation, custom popup, and a more complex case where the popup needs a custom view model. It also shows Prism’s InvokeCommandAction action that passes the EventArgs from the trigger, as a command parameter. For more infromation, see Interactivity QuickStart.

NuGet Packages Now Available

In your application, you can now use NuGet to add references to the Prism assemblies. These packages include:


Microsoft Downloads - Prism 5.0 for WPF – April 2014

Prism provides guidance designed to help you more easily design and build rich, flexible, and easy to maintain Windows Presentation Foundation (WPF) desktop applications.


MSDN Code Gallery - Getting Started Code Sample Using the Prism Library 5.0 for WPF

In this lab and associated sample, you will learn the basic concepts of modular application development using the Prism Library, and apply them to create a solution that you can use as the starting point for building a composite Windows Presentation Foundation (WPF) application. After completing this lab, you will be able to do the following:

  • You will create a new solution based on the Prism Library.
  • You will create and load a module.
  • You will create a view and show it in the shell window. 

This lab includes the following tasks:


MSDN Code Gallery - MVVM Code Sample using the Prism Library 5.0 for WPF

The Model-View-ViewModel (MVVM) QuickStart provides sample code that demonstrates how to separate the state and logic that support a view into a separate class named ViewModel using the Prism Library. The view model sits on top of the application data model to provide the state or data needed to support the view, insulating the view from needing to know about the full complexity of the application. The view model also encapsulates the interaction logic for the view that does not directly depend on the view elements themselves. This QuickStart provides a tutorial on implementing the MVVM pattern.

A common approach to designing the views and view models in an MVVM application is the first sketch out or storyboard for what a view looks like on the screen. Then you analyze that screen to identify what properties the view model needs to expose to support the view, without worrying about how that data will get into the view model. After you define what the view model needs to expose to the view and implement that, you can then dive into how to get the data into the view model. Often, this involves the view model calling to a service to retrieve the data, and sometimes data can be pushed into a view model from some other code such as an application controller.

This QuickStart leads you through the following steps:

  • Analyzing the view to decide what state is needed from a view model to support it
  • Defining the view model class with the minimum implementation to support the view
  • Defining the bindings in the view that point to view model properties
  • Attaching the view to the view model



That should be enough Prism for WPF to get you started at least...

Wednesday, August 21, 2013

Free eBook #2 for the day: Dependency Injection with Unity

Microsoft Downloads - Book Download: Dependency Injection with Unity

Unity is a dependency injection container. It is full-featured, with support for instance and type interception and custom extensions. Unity 3 also supports Windows Store apps.

Version: 1

Date Published: 8/20/2013

DependencyInjectionWithUnity.epub, 1.0 MB

DependencyInjectionWithUnity.pdf, 3.3 MB

Authors: Dominic Betts, Grigori Melnik, Fernando Simonazzi, Mani Subramanian.
Foreword by Chris Tavares.

Over the years software systems have evolutionarily become more and more complex. One of the techniques for dealing with this inherent complexity of software systems is dependency injection – a design pattern that allows the removal of hard-coded dependencies and makes it possible to assemble a service by changing dependencies easily, whether at run-time or compile-time. It promotes code reuse and loosely-coupled design which leads to more easily maintainable and flexible code.

The guide you are holding in your hands is a primer on using dependency injection with Unity – a lightweight extensible dependency injection container built by the Microsoft patterns & practices team. It covers various styles of dependency injection and also additional capabilities of Unity container, such as object lifetime management, interception, and registration by convention. It also discusses the advanced topics of enhancing Unity with your custom extensions.

The guide contains plenty of trade-off discussions and tips and tricks for managing your application cross-cutting concerns and making the most out of both dependency injection and Unity. These are accompanied by a real world example that will help you master the techniques. Keep in mind that Unity can be used in a wide range of application types such as desktop, web, services, and cloud. We encourage you to experiment with the sample code and think beyond the scenarios discussed in the guide.

In addition, the guide includes the Tales from the Trenches – a collection of case studies that offer a different perspective through the eyes of developers working on the real world projects and sharing their experiences. These chapters make clear the range of scenarios in which you can use Unity, and also highlight its ease of use and flexibility.

Whether you are a seasoned developer or just starting your development journey, we hope this guide will be worth your time studying it. We hope you discover that Unity container adds significant benefits to your applications and helps you to achieve the goals of maintainability, testability, flexibility, and extensibility in your own projects. Happy coding!

While I use Unity, I'm not really very good with it (and dare I say it's mostly "bing-code"?). I'm looking at this book hoping it will help me become one with Unity.. :P


Related Past Post XRef:
Enterprise Library 6 and Unity 3 are out today... (Semantic Logging and Transient Fault Handling Application Block added, other Blocks updated)

Wednesday, August 07, 2013

Brian brings some Unity to using Prism and dynamically discovering and loading Modules at runtime

brian lagunas - Prism: Dynamically Discover and Load Modules at Runtime

If you develop WPF applications with Prism, then you are probably already aware of the many ways in which you can load a module.  Loading a module starts with what is called a ModuleCatalog.  You can’t load a module unless it has been added to a ModuleCatalog.  Once the module has been added to a ModuleCatalog, Prism will then take care of loading the module assembly for you.  Prism even comes with a handful of module catalogs to give you flexibility in how you register your modules with your Prism application.  You can populate a module catalog from code, from XAML, with XML in an app.config, or from a directory.  Heck, you can even use a combination of all these options to populate your module catalog.

When I am giving a Prism talk at a public event or an internal lunch and learn at a company, I am sure to explain all the different ways of loading your modules and which catalog to use.  This is about the time where the questions really start getting interesting.  Of these questions, the most common is about the DirectoryModuleCatalog.  This particular catalog allows you to specify a folder path to load your modules from.  Now the interesting question… “but, what happens when a new module assembly is dropped into the folder?  Will it automatically be loaded into the app while it is running?”  That is a great question, and the answer is NO.  The DirectoryModuleCatalog does a one time scan of the directory and then loads all the modules that it finds.  If you drop a new module assembly into the directory, it will not be loaded until the application is restarted.  Now the follow-up question… “well, is it possible to dynamically discover the modules and load them from the directory as well?”  Answer; well of course it is.  If you’re using MEF, it’s easy.  If you’re using a container such as Unity, you will need to write the code to handle it yourself.  “Well, we don’t use MEF, so can you show us how?”  This is where my reply is always the same, “a simple web search (Google or Bing) should help you find what you are looking for”.

Well, it turns out, that’s not the case.  It seems that no one has blogged about or shared any code that handles the dynamic discovery and loading of modules using a DI container such as Unity.  Not that I could find, nor anyone who is asking me to show them could find.  Which leads me to this post.  I am going to show you an approach that I have used to support such a scenario.  I am actually going to give you two approaches.  One is the “Quick and Dirty” way.  Basically, I will throw together the simplest sample to achieve the goal.  Then I will show you “A Better Way” in which we will encapsulate this functionality into a custom ModuleCatalog that will handle everything for us.


My name is Greg and I pretend to write LOB Prism apps...

Well I am in the middle of using Prism & Unity to build a LOB app I and I ran into exactly what Brian is blogging about. I wanted to do a runtime discovery of modules and just couldn't figure out how to do it quickly enough, so gave up and just did it the hard way. Now that Brian has shown the way, I'm going to have to revisit that... :)

Friday, April 26, 2013

Enterprise Library 6 and Unity 3 are out today... (Semantic Logging and Transient Fault Handling Application Block added, other Blocks updated)

ALM and Beyond - Microsoft Enterprise Library 6 and Unity 3 Released

Microsoft Enterprise Library is a popular collection of reusable software components (called application blocks) designed to address common cross-cutting concerns of enterprise application developers (such as logging, validation, data access, exception handling, and more). Enterprise Library is provided as source code, test cases, and documentation that can be used "as is" or extended, and encapsulates the Microsoft recommended and proven practices for .NET application development.

Unity is one of the Enterprise Library application blocks which provides a lightweight, extensible dependency injection container with support for constructor, property, and method call injection, as well as support for instance and type interception. It facilitates building loosely coupled applications (including Windows Store apps).


What’s in the Box?

  • New Blocks
    • Semantic Logging Application Block [video]
    • Transient Fault Handling Application Block (this application block was previously a part of the Enterprise Library Integration Pack for Windows Azure; in this release it has been generalized and updated to the latest technologies).
    • Updated Application Blocks – 6 blocks from previous versions have been updated:
      • Data Access Application Block
      • Exception Handling Application Block
      • Logging Application Block
      • Policy Injection Application Block
      • Validation Application Block
      • Unity Application Block/DI Container (v3.0)
  • New Programmatic Configuration – Streamlining programmatic configuration of all blocks and improving ease of learning and ease of experimentation.
  • Configuration Console – largely unchanged from the previous release.
  • Reference Implementation – To versions of the same application: one using Enterprise Library 5 and one using Enterprise Library 6 to illustrate the changes and to help users migrate.
  • Guides – The “Developer’s Guide to Enterprise Library” is designed to introduce users to the library and explain how to use it through short, practical code examples. The new “Dependency Injection with Unity” guide introduces users to the Dependency Injection pattern, describes the problems it can solve, and shows how to use the Unity container in their own applications.


InfoQ - Microsoft Enterprise Library 6.0 Adds Semantic Logging


Enterprise Library 6.0 comes 3 years after EL 5.0 with a new application block, Semantic Logging, providing consistent format and structure of logging messages based on strongly typed events. Log messages can be saved simultaneously to multiple  destinations including flat file, console window, database or Windows Azure storage. An example of generating a log message for a UI error in an application, taken from the Developer Guide (PDF), looks like this:


Grigori Melnik: Thoughts on Agile Software Engineering and Beyond - Just released - Microsoft Enterprise Library 6

Five month ago we formulated our vision for the new version of Enterprise Library. Now we are delivering on it. I’m excited to announce the latest release of Microsoft Enterprise Library: version 6.

What is Enterprise Library?

Enterprise Library is made up of application blocks, each aimed at managing specific crosscutting concerns. Crosscutting concerns are those tasks that you need to accomplish in several places in your application. When trying to manage crosscutting concerns there is often the risk that you/different team members will implement slightly different solutions for each task at each location in your application, or that you will just forget them altogether. Writing entries to a system log file or Windows Azure table storage, dealing with transient error conditions and validating user input are typical crosscutting concerns. While there are several approaches to managing them, the Enterprise Library application blocks make it a whole lot easier by providing generic and configurable functionality that you can centralize and manage.

Enterprise Library application blocks are standalone. They work well together, but you only have to get the ones that you need. They are also customizable and extensible, so you can extend them to provide what you need in your specific contexts. You can choose to use it as a seedwork and grow your own library, which you can later reuse and sell. We ship under MS-PL, so this is allowed.

What are the main themes for this release?
  • Simplifying the library all around
  • Embracing semantic logging
  • Increasing resiliency to errors
  • Enhancing Unity type registration
  • Supporting Windows Store apps (Unity, Topaz)
  • Streamlining programmatic configuration of all blocks
  • Integrating with other technologies (ASP.NET MVC and ASP.NET Web API)
  • Improving ease of learning, ease of experimentation (fast start), and ease of use




Somasegar's blog - Enterprise Library 6.0


While this 6.0 release is filled with great things to talk about, I want to highlight three in particular:

  • .NET 4.5 saw the introduction of the EventSource class, which dramatically simplifies the task of doing ETW tracing in managed applications (ETW, or Event Tracing for Windows, is a fast and scalable logging mechanism built into the Windows operating system).  Enterprise Library 6.0 includes the new Semantic Logging Application Block, which enables you to have the simplicity and power of EventSource while still utilizing log formats and storage facilities you’re familiar with.  With this block, you can easily direct your log messages to a variety of destinations, such as rolling flat files, SQL Server databases, or Windows Azure table storage, while still maintaining the structured nature that ETW and EventSource provide.  This structure makes it much easier to later aggregate, query, and process the information you've captured.
  • LOB apps are more and more likely to be running in distributed environments, where intermittent error conditions are not uncommon.  The updated Transient Fault Handling Application Block, which helps to provide resilience against such conditions, has been updated with new detection strategies and with support for the new asynchronous programming features of C# 5 and Visual Basic 11, enabling increased scalability.  It’s also now available as a portable library for use with .NET 4.5, Windows Store apps, and Windows Phone apps.
  • Previous releases of Enterprise Library have included Unity, a lightweight and extensible dependency injection container that facilitates building loosely coupled applications.  With this release, it’s seen several important enhancements, including support for Windows Store apps.

As has been the case with Enterprise Library in the past, you can easily add to your projects just the blocks you need by using the NuGet package manager in Visual Studio:


You can check out the Enterprise Library at

Microsoft Downloads - Microsoft Enterprise Library 6

Microsoft Enterprise Library is a collection of reusable application blocks designed to assist software developers with common enterprise development challenges. This release includes: Data Access Block, Exception Handling Block, Logging Block, Policy Injection Block, Semantic Logging Block, Transient Fault Handling Block, Validation Block, and Unity.

Quick details

Version: 6.0
Date published: 4/25/2013

Language: English

EnterpriseLibrary6-binaries.exe, 1.0 MB

EnterpriseLibrary6-source.exe, 7.5 MB

Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.vsix, 726 KB

SemanticLogging-service.exe, 1.0 MB

Microsoft Enterprise Library is a collection of reusable application blocks addressing common cross-cutting concerns. This release includes: Data Access Application Block, Exception Handling Application Block, Logging Application Block, Policy Injection Application Block, Semantic Logging Application Block, Transient Fault Handling Application Block, Validation Application Block, and Unity Application Block.
This major release of Enterprise Library contains many compelling new features and updates that will make developers and IT professionals more productive. Two new application blocks are:

  • Semantic Logging Application Block
  • Transient Fault Handling Application Block (this application block was previously a part of the Enterprise Library Integration Pack for Windows Azure; in this release it has been generalized and updated to the latest technologies)
Other major new features include:
  • New programmatic configuration that doesn’t require a container
  • AsynchronousTraceListenerWrapper for the Logging Application Block, which enables existing listeners to write messages asynchronously
  • JSON formatter for the Logging Application Block.
New Unity Application Block includes many improvements:
  • Registration by convention
  • Support for NetCore (Windows Store apps)
  • Resolving objects of type Lazy<T>
  • The Unity assembly is now Security Transparent
  • Support for ASP.NET MVC and ASP.NET Web API

The detailed list of all changes is included in the Release Notes.


All application blocks are also available as NuGet packages.

Microsoft Downloads - Microsoft Unity 3

Unity is a dependency injection container. It is full-featured, with support for instance and type interception and custom extensions. Unity 3 also supports Windows Store apps.

Quick details

Version: 3.0
Date published: 4/25/2013

Language: English

Unity3-binaries-only.exe, 401 KB

Unity3-binaries-symbols-source.exe, 1.6 MB

This major release of Unity includes the following new features:

  • Registration by convention.
  • Support for NetCore (Windows Store apps).
  • Resolving objects of type Lazy<T> by Unity.
  • The Unity assembly is now Security Transparent.
  • Support for ASP.NET MVC and ASP.NET Web API.

The detailed list of all changes is included in the Release Notes


Also available via NuGet.

Enough said?

Thursday, April 11, 2013

Unity vs. MEF - right for you, one is...

Visual Studio Magazine - Unity vs. MEF: Picking the Right Dependency Injection Manager

Peter Vogel compares both of the Microsoft dependency injection managers/inversion of control containers and comes up with a decision tree for picking the correct one.

I think dependency injection containers make it so much easier to implement designs that include many dedicated objects that I'm not sure I could live without one anymore. Microsoft, though, provides two: the Managed Extensibility Framework (MEF), which is part of the Microsoft .NET Framework, and the Unity Container (Unity), which is available as a NuGet download. While there are also several open source tools available, these are the two that are easiest to add to your project. So the question is: Which should you use?

I've discussed MEF and Unity separately, but it's worthwhile to take the time to discuss what I like about each of them and when to use each. One caveat: Both tools are sufficiently "feature rich" that I'm almost certain to get something wrong. I hope comments on this article will address any glaring errors on my part.

First, an overview: Both tools allow you to define containers that you can load with classes or objects. Once you load a container with classes, both frameworks will instantiate the classes and hand you back the resulting objects. Both frameworks allow you to specify what values are to be passed to constructors or used to set properties and call methods when classes are instantiated. Both containers allow you to control the lifetime of those objects -- allowing you, for instance, to specify that only a single instance of some object is ever to be created (effectively implementing the singleton pattern).


Unity vs. MEF: The Decision Tree


The good news is both MEF and Unity are excellent tools, so neither is a bad choice. The bad news is, three months after picking one, you'll run into a problem that would've been easier to solve with the other tool.


Peter's closing sentence made me laugh out loud. So, so true.

Currently I'm on the Unity track as I'm building a Prism app, and it seemed the Unity extensions just felt more natural.

Wednesday, June 27, 2012

Looking through a prism for unity... "Creating Modularity with WPF, Prism and Unity"

Visual Studio Magazine - Creating Modularity with WPF, Prism and Unity

There's a better set of tools than using Windows Presentation Foundation (WPF) straight out of the box: WPF plus Prism (formerly "Composite Application Guidance for WPF and Silverlight") and Unity. Prism focuses on letting you turn your XAML file into a true view, supported by a completely separate ViewModel class.

Because your XAML view is built declaratively, you might have blunders in it (incorrect property settings, for instance), but you can't have logic errors. Instead, your bugs are limited to your procedural code (the validation code, the integration with your business objects, workflow management and so on), which is segregated into your ViewModel class. That ViewModel class can be developed in parallel to your view and, more importantly, built using test-driven development (TDD) to ensure it works correctly. Once your view model is built, it just needs to be wired up to your XAML to create your application.

Unity focuses on giving you runtime flexibility in that "wiring up" phase by providing the ability to create composable applications -- applications that choose their parts at runtime. Instead of hardcoding class names into your code, you specify the criteria for the classes you want to use. At runtime, your application looks for the class it needs and loads it. This gives you an easier way to swap in and out your views and view models from one site to another, from one scenario to another (premium customers versus ordinary customers) or from one state to another (test versus production; supporting a customer in default versus supporting a customer in good standing). Applications determine the criteria for the components they need by reading a configuration file or by making decisions based on information in the environment.

It's a different way of thinking: Using Prism and Unity with WPF is as much about adopting a way of creating your applications as it is about adopting new technology. And while I'm focusing on WPF in this article, Prism and Unity work equally well with Silverlight, throwing in the ability to dynamically search for the classes to download to the client as a bonus.

The easiest way to get the Prism/Unity combo is to use the Extensions Manager on the Visual Studio Tools menu to search for and install the NuGet Package Manager. Once you have NuGet installed, you can right-click on your project and select Manage NuGet Packages. A search in the online forums on Prism will bring you to the Prism.UnityExtensions package, which you can download and install into your project.



Been a while since I've highlighted a Prism/Unity post or article. I've been hearing Prism/Unity noises around me so wanted to grab this for future sharing/etc. Plus I thought it cool that we're seeing this a few days early (the article post date is 7/1/2012 and today is 6/27/2012). Finally I just liked the depth and detail...

Thursday, February 16, 2012

All in One Unity Demo and Information Series

CodePlex - Unity All In One

This projects intends to show features in Unity and different ways of working with it.

A couple of thing to know before starting is how the project is structured. The launching point for this project is UnityDemo.ConsolePresenter which has the Program files. To make it more relatable i've used the Duck analogy from HeadFirst deisgn pattern but in my own way. Solution has a Common and a Unity code Library folder where all the samples lie. Feature's are mostly broken down as assemblies . It's best to start with UnityDemo.RegAndResCode project but after that you can go through any feature you like. For convenience sake I have a dictionary or Features and within it a dictionary of Samples. All you have to do is change the index number to go directly to the code class. A detailed explanation about each feature can be found here

Features sampled uptill now are :

  1. Regitsering types
  2. Resolving Types
  3. ResolveAll
  4. DependencyAttribute
  5. LifeTime manager
    1. Transient
    2. ExternalControlled
    3. ContainerControlled
    4. PerThreadControlled
    5. HierarchicalLifetimeManager
  6. Injcetion constructor
  7. AutomaticFactory
  8. Interception
  9. Confuration File
    1. Adding Intellisense Support

..." [GD: Project Description Leach Level: 99%]

Unity All in One : 2 of N : Adding Intellisense in the App.config

"Visual studio Intellisense is one of the best feature’s in Microsoft arsenal. So if at any point I don’t have it working for me I end up spending more time then I probably should be. This is specially true while configuring the config file for Unity. May be I’m jumping ahead. Lets step back to the most crucial question here

“Why should i use a config file at all for Unity ? “

I generally tend to have behaviours and model split across assemblies. So there may be a situation where I havent referenced an assembly. But I know that by the time you get here it’ll be registered. So no harm done. But that just me.

Ok moving forward. How do I get an Intellisense in the config file for Unity configurations ? . The problem is Visual studio doesn’t have a schema defined for the Unity’s configuration section. A simple way would be to install the Enterprise Library by Microsoft. It come with a schema for Unity. To verify if you have a schema follow the mentioned steps


This looks like a great resource, both the Codeplex Project and the blog, for getting up to speed and checking out Unity...


(via Microsoft Developer Network - Samples - Unity All In One)

Monday, August 01, 2011

Can we get a little Unity?

Developers' Hangout Blog - Introduction to Unity Application Block 2.1

“In this post I would like to do a simple introduction to Unity Application Block. Unity is a framework that supports dependency injection (DI) in constructors, properties, and method calls. Unity also supports intercepting method calls which I may cover in a later post.

The documentation for Unity is pretty detailed, so it is probably a good place to start for background information. I’ve also included a link to the download area in the references section at the bottom of the post.

What is Unity and why would you use it?

When you start a project, the code base is usually small so it is not difficult to maintain or test. As the project gets larger, it is often the case that it gets broken down into components, and each component is created separately, and then integrated into the rest of the project.

In the beginning, the components are self contained and testable on their own if the person doing the work was paying attention to object oriented design principles. Even if the component was carefully constructed, at some point during integration it is usually the case that component boundaries begin to break down and components start having strong dependencies on each other.

Part of the break down of component boundaries happens because components start to inherit responsibility for configuring the dependencies with other components. Once a component has built in knowledge on how to create and configure another component, it becomes difficult to separate the components and test them independently.

This is where Unity comes in. Not only does Unity take the responsibility for creating and configuring components, it does so in a consistent way. Components don’t have to know where their dependent components come from. In addition, Unity can automatically create the dependent components if, necessary, or use existing instances.


Been a good while since I’ve blogged about, or [sheepish grin] looked at, Unity so a review of it, what it can do and how it can help use build better apps is timely…


Related Past Post XRef:
IoC? What? Man, I’m just a line of business dev trying to get through my day… What is this inversion of control/IoC, Dependency Injection thing?
Still trying to figure out what DI/IoC but are afraid to speak up?

Writing a MMC Plugin, with MVP and Unity
The Microsoft Patterns & Practices Catalog Cheat Sheet
Microsoft Enterprise Library 5.0 and Unity 2.0 RTW (& EntLib 3.x, 4.x to 5.0, Unity 1.x to 2 Migration Guide)

Saturday, January 15, 2011

Writing a MMC Plugin, with MVP and Unity

Damian SchenkelmanMMC 3.0 Sample Plug-In using MVP and Unity

“The last couple of days I have been working on a MMC spike that leverage dependency injection and some kind of presentation pattern (in this case MVP), to search for ways to make MMC applications more testable. The scenario I chose for the spike was having a plug-in that could connect/disconnect network adapters through a service that used WMI objects. The sample is very fresh, and there is still work to do to decouple things a bit more (for example, moving strings for WMI objects to config files).

To work with MMC, you need the Microsoft.ManagementConsole.dll assembly, which comes as part of the Windows SDK 6.1 for Windows Server 2008. This is important because versions 7.0 and 7.1 do not include this assembly. Additionally,  “MMC is one of the very few extensibility point in the OS that will not support .NET 4. MMC ” (from this thread), which is why MEF went out the door and in came Unity.


This is one of the edge case dev projects that many of us don’t usually encounter, the writing of an MMC Plugin. Given that I really like Damian’s approach the building of this MMC Plugin sample. MVP & Unity is just not something I’d really have thought of, though I should have, when building one…

Wednesday, April 21, 2010

The Microsoft Patterns & Practices Catalog Cheat Sheet

J.D. Meier's Blog - patterns & practices Catalog at a Glance

“Periodically I create a simple summary table of our patterns & practices collection of assets.  This helps me analyze the collection as a catalog.  To keep it incredibly simple, I organize the catalog by guidance types.  This way, at a glance, I can see the collections of guides, patterns, factories, reference implementations, and EntLib.  In this case, I also added any work in progress that I was aware of to get a real bird’s-eye view of the catalog.



In short, don’t reinvent the wheel if you don’t have to…


Related Past Post XRef:
[There’s just to many to reference, I’ve blogged about many/most of these in the past, please search or check the appropriate tags on the right of the blog… thanks :]

Microsoft Enterprise Library 5.0 and Unity 2.0 RTW (& EntLib 3.x, 4.x to 5.0, Unity 1.x to 2 Migration Guide)

Grigori Melnik: Thoughts on Agile Software Engineering and Beyond - Microsoft Enterprise Library 5.0 Released!

“Last Friday I signed off on the last quality gates!  Yesterday we had our Release Readiness Meeting, which gave a resounding GO to the Enterprise Library 5.0 and a round of applause to the team. As one of the directors concluded “It is a beautiful thing… Not just the product, but also how you’ve got there.”

And now… a drum roll, please. On behalf of the patterns & practices Enterprise Library team I am very excited to announce the world-wide availability of Microsoft Enterprise Library 5.0.

What is Enterprise Library ?

Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development challenges (such as logging, validation, caching, exception handling, and many others). Application blocks encapsulate Microsoft recommended development practices; they are provided as source code plus tests and documentation that can be used "as is," extended, or modified.



Microsoft Downloads - Microsoft Enterprise Library 5.0

“Microsoft Enterprise Library is a collection of reusable application blocks designed to assist software developers with common enterprise development challenges. This release includes: Caching Block, Cryptography Block, Data Access Block, Exception Handling Block, Logging Block, Policy Injection Block, Security Block, Validation Block, and Unity.

Version: 5.0
Date Published: 4/20/2010
Language: English
Download Size: 5.3 MB - 16.4 MB*

This major release of Enterprise Library contains many compelling new features and updates that will make developers more productive. These include:

  • Major architectural refactoring that provides improved testability and maintainability through full support of the dependency injection style of development
  • Dependency injection container independence (Unity ships with Enterprise Library, but you can replace it with a container of your choice)
  • Programmatic configuration support, including a fluent configuration interface and an XSD schema to enable IntelliSense
  • Redesign of the configuration tool to provide:
    • A more usable and intuitive look and feel
    • Extensibility improvements through meta-data driven configuration visualizations that replace the requirement to write design time code
    • A wizard framework that can help to simplify complex configuration tasks
  • Data accessors for more intuitive processing of data query results
  • Asynchronous data access support
  • Honoring validation attributes between Validation Application Block and DataAnnotations
  • Integration with Windows Presentation Foundation (WPF) validation mechanisms
  • Support for complex configuration scenarios, including additive merge from multiple configuration sources and hierarchical merge
  • Optimized cache scavenging
  • Better performance when logging
  • A reduction of the number of assemblies
  • Support for the .NET 4.0 Framework and integration with Microsoft Visual Studio 2010
  • Improvements to Unity


Microsoft Downloads - Microsoft Enterprise Library 5.0 Migration Guide


Version: 5.0
Date Published: 4/20/2010
Language: English
Download Size: 649 KB - 1.3 MB*

This guide explains the opportunities open to you for migrating applications built using Enterprise Library versions 3.1, 4.0, and 4.1, and versions 1.0 and 1.1 of Unity to use version 5.0 or Enterprise Library and version 2.0 of Unity.

Because individual application scenarios and environments vary, and the way Enterprise Library and Unity are used within existing applications will differ considerably, this guide cannot guarantee success in every situation. However, it contains practical guidance that is based on knowledge gathered during the development of Enterprise Library 5.0, and through test migrations of a range of different existing applications.

It’s like a RTM/RTW kind of month…


Related Past Post XRef:
Enterprise Library 4.0 RTW (May 2008)
Unity 1.0, Microsoft's Dependency Injection, Inversion of Control (DI/IOC) Container, has RTW'ed
Enterprise Library 3.0 - April 2007 Released
Enterprise Library for .NET Framework 2.0 RTM (January 2006)
Enterprise Library MSN Messenger Log Listener
"Avanade Integration Pack for Microsoft Enterprise Library Released"
Enterprise Library Logging : Rolling Flat File Sink
Microsoft Enterprise Library Tutorials
Microsoft Enterprise Library WebCasts
Download details: Enterprise Library
Enterprise Library (New release of the patterns & practices Application Blocks)

Wednesday, April 29, 2009

Reference Assistant – Commercial (with free 30 day trial) Visual Studio Add-in to help cure IoC reference headaches

Darren’s Blog - Announcing Reference Assistant 1.0

“The product I have been working on, Reference Assistant, was released a few weeks ago.  Reference Assistant is an extension for Visual Studio 2005 and 2008 (and soon 2010).  In short, the goal of the product is cut down the time spent debugging runtime errors due to missing dependencies or errors in configuration.


Here are a few highlights of the capabilities in version 1.0:

  • Configuration files for, Windsor, and Unity can be parsed and displayed visually in a tool window.  Missing or incorrectly spelled types are pointed out (project reference paths are searched for required dependencies). 
  • Navigation to object definitions in supported IoC/DI configuration files
  • Any dependencies detected in configuration files can be automatically copied to the project output directory upon successful build.
  • Reference Paths can be setup automatically using rules setup in preferences.
  • Version conflicts between dependencies are displayed visually and in a tool window.
  • Generate a report of all required assemblies for a project’s deployment, including dependencies defined in IoC framework configuration files.
  • Extensions can be written to support custom file formats or configuration types.

For more detail in addition to the product pages, we have written a blog post walking through the functionality available in Reference Assistant for XML configuration.


“Friend of the Blog” Darren Stokes, of Visual Studio Links fame (yes, Daren, Fame!.. Is Visual Studio Links is cool and a must read link blog for Visual Studio developers, so just accept the adulation… ;) has recently released this cool sounding Visual Studio Add-in to help resolve reference pain and suffering. I don’t yet use Spring, Windsor, Unity (yeah, I know, I’m lame… um… shut up?  ;) but I can still see how this add-in could come in real handy.

Friday, April 04, 2008

Unity 1.0, Microsoft's Dependency Injection, Inversion of Control (DI/IOC) Container, has RTW'ed

Microsoft Downloads - Unity Application Block (RegWare)


The Unity Application Block (Unity) is a lightweight, extensible dependency injection container. It facilitates building loosely coupled applications and provides developers with the following advantages:

  • simplified object creation, especially for hierarchical object structures and dependencies.
  • abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns.
  • increased flexibility by deferring component configuration to the container.
  • service location capability; this allows clients to store or cache the container.


  • Microsoft .NET Framework 2.0, 3.0, or 3.5
  • Microsoft Visual Studio 2005 or Visual Studio 2008 development system (any of the the following editions):
    • Stand Edition
    • Professional Edition
    • Team Edition for Software Developers
    • Team Edition for Software Testers
    • Team Edition for System Architects
    • Team Suite
  • " [Description leached in near full]

    Microsoft Downloads - Unity Application Block Documentation for Visual Studio 2005

    "The integrated documentation for the Unity Application Block (Unity) to be used with Visual Studio 2005.


    Microsoft Downloads - Unity Application Block Documentation for Visual Studio 2008

    "The integrated documentation for the Unity Application Block (Unity) to be used with Visual Studio 2008.


    Now if only I truly knew how to best use and apply this...

    Oh well, I guess you have to start somewhere.  :)

    Saturday, February 23, 2008

    More IoC - A Castle Windsor and Unity Application Block Comparison

    Matthew Podwysocki's Blog - IoC and the Unity Application Block - Going Deeper

    "I thought after my recent F# post, I'd get back to the Unity post that was halfway done before the firestorm began...

    In a previous post, I showed how easy it was to create a basic application using the Unity Application Block. I'm always finding new ways to solve my problems and new tools to do it.  Since Inversion of Control (IoC) containers are near and dear to my heart, I thought I'd investigate to see whether it meets my needs or not.  It's something you need to determine on your own, whether it works for you.  Some like Spring.NET, others StructureMap, Castle Windsor and so on.


    Compare/Contrast with Windsor

    Anyhow, today I will focus on a little compare/contrast with Castle Windsor just to show the different styles used.  I'm not going to say one is better than the other, because quite frankly, that's up to you to decide...  I want to thank Dustin Campbell for his help in getting a better code formatter via this post here.


    More IoC (Inversion of Control) reading material.

    Also I believe this is my first reference to the very recently released Unity Application Block (a "lightweight extensible dependency injection container with support for constructor, property, and method call injection").


    Related Past Post XRef:
    Getting to know IoC (Inversion of Control) Container
    Take a Lunch Break with Windsor IoC Container (part of the Castle Project)