Amazing. thanks for the tip, works perfectly!
> Yes.
> Cheers,
> Nick
> On 26 November 2010 11:38, Shandem <sdemin...@gmail.com> wrote:
> > Ok great, but if i register TestData like the above, will it be able
> > to be injected into non-MEF dependencies as well?
> > Thanks,
> > Shannon
> > On Nov 26, 8:33 am, Nicholas Blumhardt <nicholas.blumha...@gmail.com>
> > wrote:
> > > Hi Shandem,
> > > You need to mark the TestData type:
> > > builder.RegisterType<TestData>()
> > > .Exported(x => x.As<TestData>());
> > > There are differences between the way MEF and Autofac handle service
> > > contracts that make this necessary for a correct integration. Given that
> > the
> > > exported types form the "public" extensibility API of your application,
> > it
> > > is probably not a bad idea to select them explicitly anyway.
> > > Cheers,
> > > Nick
> > > On 25 November 2010 16:51, Shandem <sdemin...@gmail.com> wrote:
> > > > Hi,
> > > > Say i have an object in my main DLL:
> > > > TestData
> > > > then i register this type in my container:
> > > > builder.RegisterType<TestData>()
> > > > Say i have an object in my plugins DLL:
> > > > [Export]
> > > > public class MyObject {
> > > > public MyObject(TestData testData) {...}
> > > > }
> > > > then i register my plugins DLL:
> > > > var catalog = new DirectoryCatalog(m_HttpServer.MapPath("~/Plugins/
> > > > Stuff"));
> > > > builder.RegisterComposablePartCatalog(catalog);
> > > > when i resolve MyObject, it tells me that:
> > > > The request service 'ContractName=TestData' has not been registered.
> > > > I've looked in the source of Autofac and it appears as though
> > > > ComponentsForContract it checks if components are registered using the
> > > > RegistrationsFor method. Inside of that method, it ONLY looks for
> > > > services that are of type:
> > > > ContractBasedService
> > > > Unfortunately, the TestData service isn't registered as a
> > > > ContractBased service and only as a TypedService because it wasn't
> > > > registered using the MEF extensions.
> > > > A 'workaround' which does work is to register my test service 2 times
> > > > and mark it with an Export attribute:
> > > > builder.RegisterType<TestData>()
> > > > builder.RegisterComposablePartType(typeof(TestData));
> > > > This DOES work but is not really ideal.
> > > > Is there any reason why Autofac forces the search for dependencies on
> > > > MEF components to be ContractBasedService ?
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Autofac" group.
> > > > To post to this group, send email to autofac@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > autofac+unsubscribe@googlegroups.com<autofac%2Bunsubscribe@googlegroups.com >
> > <autofac%2Bunsubscribe@googlegroups.com<autofac%252Bunsubscribe@googlegroup s.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/autofac?hl=en.
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Autofac" group.
> > To post to this group, send email to autofac@googlegroups.com.
> > To unsubscribe from this group, send email to
> > autofac+unsubscribe@googlegroups.com<autofac%2Bunsubscribe@googlegroups.com >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/autofac?hl=en.