Hi,
Indeed, I should have used
.BasedOnIViewWindow()
.WithServiceFromInterface()
.WithServiceSelf()
But I didn't know that *Services are cumulative*.
I guess I should have read the entire
page
http://docs.castleproject.org/Windsor.Registering-components-by-conventions.ashx
Or pay more attention...
On Friday, May 29, 2015 at 10:49:28 AM UTC+3, hammett wrote:
WithServiceSelf should have done the trick.
The container has a nice debugger view - could you check what it shows
to you? just hit a breakpoint where the container instance is
accessible/in-the-scope, and see what is in there...
On Thu, May 28, 2015 at 11:17 PM, bdaniel7 bdan...@gmail.com
javascript: wrote:
I'm reposting from here
http://stackoverflow.com/questions/30510942/multiple-registrations-with-castle-windsor
I have the following situation in a WPF application:
public class ExpenseView : UserControl, IAccountingView {}
// just a marker, the contract is in IViewWindow
public interface IAccountingView : IViewWindow {}
And I need to be able to register ExpenseView to be resolvable in two
ways,
as concrete type, ExpenseView and as IAccountingView (and maybe as
another
interface as well).
I'm registering the types like this:
// I need a collection of IViewWindow to be used
Container.Register( Classes.FromAssemblyInDirectory( myTypes )
.BasedOnIViewWindow()
.WithServiceFromInterface()
.LifestyleTransient()
);
// all other types don't have interfaces, are used as concrete types.
Container.Register( Classes.FromAssemblyInDirectory( myTypes )
.Where( type = type.IsPublic )
.WithServiceSelf()
.LifestyleTransient()
);
Now, this works, ExpenseView and all other types are instantiated,
except
that when I need to use
var newInstance = container.Resolve( iView.ViewType );
to get another instance, where iView.ViewType is the concrete type
ExpenseView (as per the example), I get this exception:
'Castle.MicroKernel.ComponentNotFoundException'
No component for supporting the service ExpenseView was found.
Any ideas why is this happening and how to make it work?
Thank you,
Daniel
--
You received this message because you are subscribed to the Google
Groups
Castle Project Users group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to castle-project-users+unsubscr...@googlegroups.com javascript:.
To post to this group, send email to castle-pro...@googlegroups.com
javascript:.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.
--
Cheers,
hammett
http://www.d-collab.com/
http://www.hammettblog.com/
--
You received this message because you are subscribed to the Google Groups
Castle Project Users group.
To unsubscribe from this group and stop receiving emails from it, send an email
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.