Friday, February 6, 2009

Windsor and Automatic Properties

When maintaining an old application that uses Windsor as DI framework, a strange NullReferenceException throwed when trying to resolve an instance of a specific class. Our project has been recently upgraded to VS 2008 so it was natural to use C# 3.0 specific features. One thing I used in the failing class was Automated Properties. The implementation looked like this :

public class GridRepositoryFactory : IGridRepositoryFactory
{
public GridRepositoryFactory(IDynamicFormDataService dataService)
{
this.Service = dataService;
}

public IDynamicFormDataService Service
{
get;
private set;
}
}
as the stacktrace showed, Castle Windsor version 1.0.3.4333 does not work correctly with inject automated properties. I had to use properties with backing field to solve this, but updating to a more recent version may also get it fixed.
Submit this story to DotNetKicks Shout it

No comments: