Category: ALT

NET Event–Migrating WinForm application

Last month (21st of July 2011) I spoke at the Bermuda NET Event “Migrating WinForm applications to WPF/Silverlight”. This has been for me the first NET Event in Bermuda but for sure it will not be the last one. We are planning to have a new event this autumn where we will touch other topics like: ALM, Parallels and more.

Thanks to Alessio Bellisomi, the web developer that works in my company, I am able to share with you some nice pictures of the event and three short movie of the event. Unfortunately, for this event, we were not super organized so I do not have with me the full video of the entire event. I promise that for the next event we will provide the entire video and maybe we will be also able to stream the content.

The audience, considering that we were in Bermuda and considering that it was end of July, was more than expected. I believe we were around a 30/40 ish attendees. The feedback has been really positive and we expect a very fast grow of this UserGroup by having more events and more speakers.


The pictures are available through Google photos



The videos have been hosted on my Vimeo account and they can be viewed through their web site

Bermuda WinForm event, part 01 from Raffaele Garofalo on Vimeo.

Bermuda WinForm event, part 02 from Raffaele Garofalo on Vimeo.

Bermuda WinForm, part 03 from Raffaele Garofalo on Vimeo.


Special thanks need to go to Sandra de Silva (president of the UG and owner of Nova Ltd) and to the other members of the committee. I want also to thank all the participants and I hope this autumn there will be more!

TypeMock tutorial #01. Startup.

The best way to learn a tool is to try it, test it and then finally use it over your code. Of course if the tool provides also a great community support and a great documentation the task will be easier.

Some weeks ago we started to adopt a wonderful tool to create mockups and other TDD fancy stuff, the tool is TypeMock.

The idea I got is to create a series of tutorials about TypeMock and provide to you a piece of a code to download a full license of this tool. At the end of the series (probably 1 month) you will be able to enable your 10 days trial into a full working license. I will create a sort of bid and from all my readers that will contact me to get the license I will come up with one or two free licenses.

Guys, consider that one license of TypeMock is 800 $ !!

Setup and Installation

In order to start right away with TypeMock you need to download the latest version of the tool (at this time they have the version 6.0.10) but be careful because they upload new versions often. The product you need to download for .NET is Isolator.NET. They also provide additional tools that we will analyze during this series, like:

  • TestDriven.NET, an integrated test runner for Visual Studio
  • Isolator for Sharepoint
  • Isolator for ASP.NET and ASP.NET MVC
  • TeamMate, a useful tool to monitor your TDD approach
  • Isolator ++, the same version but for C++
  • TestLint, a nice tool that will help you to develop your TDD skill

and more.

After you have downloaded the setup (7 Mb) you will have to follow a very straightforward setup wizard with only two options available; use the advanced option and install everything including the samples for .NET.

That’s it, you are now ready to go!

File Location

TypeMock is installed on your C:\ drive and depending on where you choose to install it, you should have a folder called TypeMock/Isolator/6.0 on your Program Files directory. Inside this folder you can find all the assemblies available from TypeMock.

You do not need to use them directly as TypeMock is also installed on your GAC folder but if you plan to work with C.I. (Continuous Integration) you may probably need to add a reference to these files instead of pointing directly to the GAC, depending on what type of build server you are working with … Winking smile

Inside the folder Examples you will find a set of useful examples to start to learn TypeMock quickly but do not worry as I will go through all these examples in this series.

If you want to make your experience with TypeMock easier and smoother, I kindly suggest you to download and install also TestDriven.NET or Resharper with Gallio. I personally use and love Resharper so you will find in this series all the reference examples pointing to the Resharper UI inside Visual Studio. The choice is up to you but I personally believe R# is the best tool so far for Visual Studio (IMHO)

Visual Studio integration

After the installation you can open Visual Studio and this is the surprise you will find in the IDE:

Screen shot 2011-06-13 at 11.56.00 PM You will find a new menu on Visual Studio called TypeMock; in this menu you can setup the license, the profiler to use with TypeMock and few other options for a better Visual Studio experience.

There aren’t a lot of other ways to easily configure TypeMock but we will see together how you can tackle each of the common tasks you may encounter while working with TypeMock.

From this menu you have also the easy option of enabling/disabling TypeMock at anytime so that you can or cannot work with it without the need to restarting Visual Studio every time (like you have to do with other plugins of Visual Studio).

The Demo Project

I have created a very small project for this series of tutorials to show you how you can test every single layer of a .NET application using TypeMock to separate the dependencies. The structure of the demo project is in the following way:

Screen shot 2011-06-19 at 4.26.58 PM

The project is composed by 4 different layers:

  1. TypeMockDemo: the project that contains the Domain Model of the tutorial
  2. TypeMockDemo.DataLayer: a data layer built around NHibernate 3.2
  3. TypeMockDemo.ServiceLayer: the service layer used to write the business logic around the domain and the data layer
  4. TypeMockDemo.UserInterface: an application developed using WPF 4.



For each project there is a corresponding “fixtures” project that includes all the fixtures related to the project. With fixture I mean “test” … Winking smile

Tutorials and resources

Before starting to follow this series I kindly suggest you to have a look at the TypeMock web site learning content, so that you will follow better my tutorials. As you know, I do not usually go too deep into a specific topic, so if you need to learn also what TDD is, I kindly suggest you to read also the following tutorials about TDD and testing in general.

TypeMock learning content:

TDD learning content:


So stay tuned and I’ll see you next Friday for the next part of this series.

Book review: Beginning ASP.NET MVC 1.0

A dear friend of mine, Simone Chiaretta, ASP.NET MVP wrote an interesting book about ASP.NET MVC in collaboration with Keyvan Nayyeri.


The book is Beginning ASP.NET MVC 1.0, edited by Wrox, available on at this address for the price of 31.49 USD.

I am going to write a review of this book because, first of all, I know Simone and his professionalism. Second, because I am working now on an ASP.NET MVC project in my company, and this book was really helpful for me, so I am pretty sure that it will be the same for you guys.

Summary and structure of the book.

The book has 19 chapters plus a couple of appendixes. Each chapter covers a specific argument. At the end of each chapter there is always a section for the exercises and a summary section. The first thing you will like about this book is the huge amount of sample code!

At the end of the book there is the appendix B that contains all the solutions related to each exercise, so you won’t get lost.

The appendix A has a lot of useful links that you can follow, resources, links, books and more.

Finally there is the index that is done for a “dev” reader. It’s not a normal index but an index divided by alphabetic order that includes also all those components and “code” that you will find in the book. So you will find, for example, the page that talks about “NHibernate”.

Case studies.

What I really liked about this book is the 2 case studies that you will find at the end. Simone has created these 2 case studies that will reflect 2 real solutions, one is a blog and the second one is … a surprise. I am not going to tell you everything because you must buy it. Wink

This is something really well done as you will apply all the knowledge you got through the book into 2 real solutions!


Of course I am not going to describe each chapter, but this is the list of chapters so you can understand why this book is so well done, IMHO:

  1. MVC pattern
  2. WebForm VS MVC
  3. Getting started
  4. The model
  5. The controller
  6. The view
  7. Routing
  8. Unite test concepts
  9. Testing ASP.NET MVC
  10. Components
  11. Action filters
  12. AJAX
  13. Deployment
  14. Leveraging ASP.NET WebForm futures
  15. Authentication and authorization
  16. Extend ASP.NET MVC
  17. Migrating from ASP.NET
  18. Case studies
  19. Resources
  20. Exercises solutions

Final Considerations.

I am a NET developer, most of time I develop Silverlight/WPF or WinForm applications. For fun I did a couple of ASP.NET MVC applications in the bank where I was working before, but my knowledge about ASP.NET MVC was relative to those projects.

Now that I got this book, I was able to read all the aspect of MVC pattern applied to ASP.NET and I feel comfortable to build a real application with this framework.

I did a real ASP.NET MVC application for the Company where I am working now, and I was able to do everything is less than 1 week, including the use of JQuery and AJAX.

I am really satisfied of this book and I hope that you will buy it as it is a very nice and well written book that will drive you inside this pretty cool framework.

Thanks Simone and Keyyvan for your effort!


Real guide, configure Exchange 2003 SP2 and iPhone 3.0 OS.

Hi guys, as I told you in the previous post, I bought a new iPhone 3GS with the new OS 3.1. The phone is pretty cool, it works great and it has tons of software, utilities and services that I didn’t find in any smart phone, including the BlackBerry.

The only big problem was to configure my business exchange email. Simply, it was not working until today. So in this small guide I am going to explain step by step what you have to do in order to have a full functional and working iPhone!

Configure ActiveSync on Exchange Server 2003.

Before starting you must successful enable ActiveSync and OMA (Outlook mobile access) into your Exchange Server. If this step will not be successful, do not go ahead!!

In order to use ActiveSync on your exchange 2003 you must have:

  1. Windows Server (standard or enterprise) with the latest updates and the Service Pack 2 working.
  2. Exchange 2003 with latest updates and Service Pack 2 installed and working.
  3. Outlook Web Access working and accessible from outside your Network.
  4. Firewall ports (443, 80) opened for OWA.

If you cannot satisfy one of these prerequisites, please Google and search for a solution. I am not going to explain here how to enable a port into your firewall or how to install OWA in Exchange Server 2003, as in my opinion, out of topic.

After you have successfully installed ActiveSync, you will have this additional option inside your server, you have to right click on global settings>mobile services and choose properties :


You have to enable everything in order to have full access to the OMA service.
After that, you should now download and install the Microsoft Exchange Server ActiveSync Web Administration Tool, and handful tool that allows web administration of your smart phones.

After you will install the tool, you will have this web application in Exchange local host:


The address is https://localhost/mobileadmin and for default is SSL enabled.

Troubleshoot OMA installation.

This step is fundamental. If you cannot access the OMA web site, you will not be able to use your iPhone or any other smart phone.

Give it a try, inside Exchange, by typing the address https://localhost/OMA and insert your Exchange credentials. If you will see a text page with your mail folders, you are fine, otherwise you need to troubleshoot the problem … If it’s working go directly to the iPhone Configuration step.

First of all open exchange active directory inside exchange and click exchange tasks over your user account. You have to enable all the futures, like this screenshot:


If it’s not working yet … like in my situation, you have to configure a new virtual directory for OMA. In order to configure the virtual directory, follow, step by step this Microsoft TechNet article or the HTTP error codes. It solved my problem.

Remember: until you get the OMA web site working, do not try to configure the iPhone!

Configure your iPhone.

I have an iPhone 3GS with OS 3.1, so probably if you have an older version, the screenshot below, will not be the same as mine.

Open the iPhone menu, click over Settings and then the menu Mail, Contacts and Calendars.

Insert a new account, choose an Exchange account.


Server: I typed my web mail address, like, without https. Then I choose the SSL enabled communication. You if you have a public URL for OMA then you have to type that address.
Do not type something like mymachinename.domain.whatever of course it will not work because your iPhone is not in your Office Network.

Username: it’s my Windows username I use in the office.

Domain: it’s my Active directory domain.

After that, you will be prompted for which objects you want to keep sync. I choose all of them like this screenshot:


After this step, after 5 minutes, you will be able to open your email and work with push technology, this means that you will be able to work directly inside your mail box from your iPhone. For example, if you add an event in the iPhone calendar, this will be added also into your mailbox in the office, and so on …

This will be the final result, pretty cool!!


Enjoy and please beware about the iPhones screenshots, for each version of the OS (2, 2.1, 3, 3.1) they change a little bit, but the information are always the same.

Personal Considerations from BlackBerry to iPhone.

  • Advantages
    • IPhone is more useful, the usability is better than BlackBerry and the screen more clear.
    • The contacts search, merge and copy options are awesome. BB is not so awesome …
    • The emails can be zoomed just with a finger, with the BB you cannot.
    • You can read Office, Acrobat, Images and Video in the mails, BB cannot.
  • Disadvantages
    • The most important is the battery life. My iPhone in a production environment doesn’t live more then 10 hours. The BB has a battery life of 3/4 days, always on.

Finally, Microsoft Exchange is the best as an Email server and the activesync service is very good, but the best match for me is Exchange server with IPhone, very impressive!!

Additional Resources:


Silverlight UserGroup Starter Kit

I have an exiting news today.

A couple of days ago, one of my friends David Silverlight asked me about a new project called Silverlight UserGroup Web Starter Kit. At the beginning I was afraid about the free time that I do not have but then I tough “this should be a good way to learn RIA services and EF in depth” …

So here we go. This is the codeplex address: and the project seems to be really cool, especially for the people that are going to work with me.

Oh boy, finally I can be part of a challenging project using Entity Framework, RIA services and C#.

Stay tuned!

NHibernate, collection with composite-id.

In the previous post we saw how to map an entity with a composite-id.

Well but now if you have mapped an entity in this way and you need to create a collection of this entity or maybe you have a related child class that uses this primary keys … you are in trouble! Smile

The way to solve the problem is very easy. First of a short example to understand what I’m talking about:

   1: class Foo {

   2:     public string name { get; set; }

   3:     public string lastname { get; set; }

   4:     public IList<childfoo> listofchild { get; set; }

   5: }

   6: class childfoo {

   7:     public string name { get; set; }

   8:     public string lastname { get; set; }

   9:     public Foo father { get; set; }

  10: }

Now the first class will be mapped in this way if we assume that “name and lastname are the primary keys”. (Also remember to override Equals() and GetHashCode()!!).

   1: <class name="Foo" table="[Foo]" schema="xxx">

   2:   <composite-id>

   3:     <key-property name="name">

   4:       <column name="[name]" sql-type="varchar" length="50" not-null="true"/>

   5:     </key-property>

   6:     <key-property name="lastname">

   7:       <column name="[lastname]" sql-type="varchar" length="50" not-null="true"/>

   8:     </key-property>

   9:   </composite-id>

   1: <bag name="listofchild" table="[childfoo]" inverse="true"

   2:    cascade="all-delete-orphan" generic="true" lazy="true">

   3:   <key>

   4:     <column name="[name]" sql-type="varchar"/>

   5:     <column name="[lastname]" sql-type="varchar"/>

   6:   </key>

   7:   <one-to-many class="Foo" not-found="ignore"/>

   8: </bag>

Now we can go back to the child mapping file and reference the many-to-one foreign mapping in this simple way:

   1: <many-to-one name="Foo" lazy="proxy" not-null="false">

   2:   <column name="[name]" sql-type="varchar"/>

   3:   <column name="[lastname]" sql-type="varchar"/>

   4: </many-to-one>

So now my repository will be able to give me:


And in that moment my repository will go back and execute the sub-select.

NHibernate and the composite-id.

I’m working with the new version (2.0 GA) of NHibernate. The problem I have encountered today is about the composite-id.

Let’s say we have an entity that doesn’t have a personal id field. We don’t want to use the GUID or any other auto id generator class. We must implement the primary key logic in the corresponding table in the database. Now, imagine to have this table:

Key Column Name SQL Type Not null
yes Field01 varchar true
yes Field02 varchar true
yes Field03 varchar true
yes Field04 varchar true

At this point we will have a mapping XML in NHibernate in this way:

   1: <class name="classname" table="[tablename]" schema="schemaname">

   2:   <composite-id>

   3:     ... ...

   4:     <key-property name="Field02">

   5:       <column name="[Field02]" sql-type="varchar" length="5" not-null="true"/>

   6:     </key-property>

   7:     <key-property name="Field03">

   8:       <column name="[Field03]" sql-type="varchar" length="5" not-null="true"/>

   9:     </key-property>

  10:     ... ...

  11:   </composite-id>

If we compile the DAL of our project, we will receive a fancy error:

“composite-id class must override Equals()”

“composite-id class must override GetHashCode()”

The explanation is very simple. We are saying that this class has 3 fields to implement a comparison so the NHB must know how you can compare these fields … and off course the CLR doesn’t know how to do it.

This is the solution in our entity:

   1: public override bool Equals(object obj) {

   2:     if (obj == null)

   3:         return false;

   4:     MyEntity t = obj as MyEntity;

   5:     if (t == null)

   6:         return false;

   7:     if (this.f1 == t.f1 && this.f2 == t.f2 && this.f3 == t.f3)

   8:         return true;

   9:     else

  10:         return false;

  11: }

   1: public override int GetHashCode() {

   2:     int hash = 13;

   3:     hash = hash +

   4:       (null == this.f1 ? 0 : this.f1.GetHashCode());

   5:     hash = hash +

   6:       (null == this.f2 ? 0 : this.f2.GetHashCode());

   7:     hash = hash +

   8:       (null == this.f3 ? 0 : this.f3.GetHashCode());

   9:     return hash;

  10: }

There we go!! Now you have implemented a full version of the method “Hey is this the entity I’m going to save or is this entity brand new?!?!”

Personal Consideration.

In my opinion NHB should be able to override this method by itself via reflection and not to ask you to rebuild thousand of entities if you want to use the standard pattern active Record.

Beginning ASP.NET MVC

Finally is out and I’m a friend of the Author (Simone Chiaretta)!!


ISBN: 978-0-470-43399-7


500 pages

March 2009


Beginning ASP.NET MVC is for developers who have .NET and ASP.NET experience, but want to enhance their level of knowledge and need to learn about the MVC framework. The book is simple and basic in its approach, because it allows readers to learn the concepts in a straightforward, uncomplicated way, but it still assumes a level of programming background and knowledge. This appeals to those who don’t want to get bogged down in learning ASP.NET, but need to know how to get the most out of ASP.NET MVC. The book covers all the main topics about ASP.NET MVC, and applies all of the latest Microsoft technologies to demonstrate the benefits of its usage. 

The book covers these key topics:

The concept of Test-Driven Development and unit testing
The principles of MVC pattern and the role of MVC pattern in TDD
An introduction to ASP.NET MVC and reasons to have such a new technology
How MVC pattern is implemented in ASP.NET MVC
A detailed discussion about the main elements of ASP.NET MVC including model, view, controller and routing
A detailed discussion about the main classes in ASP.NET MVC and how the abstraction and isolation is achieved for them
How to unit test an ASP.NET MVC application
Separate topics for authentication, authorization and AJAX
How to move from traditional ASP.NET webforms to ASP.NET MVC
Case studies to show the discussed topics in a practical and applicable way

You can buy a pre-sell on at this address.

Beginning ASP.NET MVC, by Simone Chiaretta.

My friend Simone Chiaretta is writing his first book about Beginning ASP.NET MVC in collaboration with Keyvan.

The book will be targeted to the developers that are not really focused on the MVC framework. This framework is new in Microsoft and it is still in a Beta version but personally, I’m using it and I have used this framework for two web project and it’s awesome!!

You can find a detailed series of articles about ASP.NET MVC, written by Simone on DotNetSlackers. I suggest to everybody to read them.

If you wanna read more details about the book, the Publishing date and related stuff, you can go directly to Simone weblog and read his post about, or go to Keyvan weblog and read his post about.