Resolving with Unity and Policy Injection using extension methods

I actually thought that this was going to be a small thing. The Unity application block is Microsoft’s IoC-container, part of the Enterprise Library. The Policy Injection application block (PIAB) is Microsoft’s AOP framework, also part of the Enterprise Library.

You’d think that it would be easy to integrate the two… But it’s not… that simple. Actually that is stranger than it first sound because apparently they are calling each other internally.

OK – I want it to be easy to combine them, so I have written two extension methods of UnityContainer that make it easer.

Here is the extension methods:

And here is some tests showing the usage:

Of course I haven’t thought this out by myself. That takes time. I want things fast. So I steal ;). Thanks goes to this blogpost...

Read More

System.BadImageFormatException Could not load file or assembly System.Data.SQLite

I ran into this problem when I tried to re-open a solution I did a while back when labbing with Fluent NHibernate and SQLite.

Behind the cryptic error message lies and easy solution; I was running the 32-bit version of the SQLite-driver and runtime. That’ doesn’t fly on my Windows 7 64-bit machine.

Here is a more through description and here is a link to the latest version of SQLite that will get you all the version (32 and 64 bits) of the SQLite.

Read More

Synchronization for consultants – it works!

I am so proud. My evil scheme to keep my calendar(s) in sync got tested for real today.

Got to new customer. Installed Outlook to Google Calendar. Started Outlook. Viola! All my events from my other calendars in place with the ones from my customer. So now they will not book me on days when I have other assignments etc.

The only thing is that you cannot think to much about it because it will drive you mad. My customer Outlook is synched with Gmail, my Avega outlook is also synched with the same account to Gmail. My phone synchs to Gmail… But it works. ‘Nuff said.

Read More

AutoMapper – get rid of your tedious mapping code

One thing that I really love being on a contract is that you’re almost immediately is forced to find solutions, whereas on a leisure project you rather do something else…

Here is another great tool; AutoMapper. It’s a framework that do all of that tedious mapping code you’re doing in for ViewModels or Messages in services. Boring and tedious to write and test. AutoMapper takes care of that – using a lot of Conventions.

Be sure to see the screencast that introduce a lot of the possibilities.

Read More

SpecFlow BDD .NET-style

In my previous post, I shared my frustrations with TDD and how to effectively start with it. BDD (Behavior Driven Development) seems to be the answer, but the .NET frameworks available for BDD can be quite perplexing. Many either have unconventional syntax or are built on top of other tools that are hard to work with.

SpecFlow appears to be a more approachable solution. It’s designed with inspiration from RSpec, Cucumber, and Ruby, but tailored for the .NET and C# environment. It offers a more familiar style for .NET developers.

Check out the SpecFlow website for more information. You can find a silent screencast that introduces its syntax and workflow, as well as great resources to get started.

Interestingly, SpecFlow even seems to support Swedish, as noted here. Kudos to the SpecFlow team for their excellent work!

I plan to explore SpecFlow further as...

Read More

ASP.NET MVC, StructureMap, and … TDD?

I’ve been experimenting with ASP.NET MVC and StructureMap (an IOC container), and the integration has been quite smooth. For guidance on combining StructureMap with ASP.NET MVC, check out Elija Manor’s blog post. Be cautious of the favicon issue.

I’m also using NHibernate and Fluent NHibernate for a cleaner configuration compared to XML. If you need to set specific properties in Fluent NHibernate, this Stack Overflow thread provides a helpful example. Additionally, the TekPub NHibernate series and Kona project examples are great resources.

Now, onto the topic of TDD. While I appreciate TDD as my preferred coding method, I’m grappling with its application at a higher level. For example, how do I decide when to introduce a repository or an IOC container, and should I TDD the IOC code?

I’ve sought advice from the Swedish ALT.NET group and found that BDD and the concept of...

Read More