views:

820

answers:

1

Hey guys, I am having trouble with Castle windsors IoC container when trying to retrieve a generic type. I have added a component using generic notation without a type argumet i.e:

<IoC>
 <components>
  <component
   id="NHibernateRepository"
   service="MobilePrototype.Domain.Interfaces.IRepository`1, MobilePrototype.Domain"
   type="MobilePrototype.Data.NHibernateProvider.Repository`1, MobilePrototype.Data" />
 </components>
</IoC>

This component is almost identical notation to that used in castles documentation here (Registering a generic type without arguments). The issue I have is that when the container tries to resolve an instance I get the following error:

 System.MissingMethodException: Method not found: 'Void Castle.Core.Configuration.ConfigurationCollection.AddRange(Castle.Core.Configuration.ConfigurationCollection)'.

Any ideas?

EDIT:

For anyone having this issue, the problem I had is that I had a reference to Castle.DynamicProxy2 and not Castle.DynamicProxy

A: 

I think Castle is not finding the configuration.

There is a missing <configuration> tag which should surround components.

If you are using the App domain, you should use the <castle> tag.

Check this out.

gcores
Well I kind of assumed that you would realize the configuration tag was there as this is held inside a .config file :-).
Owen
And what is the IoC tag doing there?
gcores
When you configure Castle you can specify the config resource i.e:container = new WindsorContainer(new XmlInterpreter(new ConfigResource("IoC")));
Owen
That configResource is the name of the xml file. It's not a tag to be put there.
gcores
Yes the configResource is the xml resource. But the constructor parameter is the sectionName. This part was NOT the problem. Please read my edit for the resolution.
Owen