you might be registering the generic IDomainEventsStorage<T> with a specific T, and then later request it with a different T.
On Tue, Dec 29, 2009 at 4:24 PM, Bhoomi Kakaiya <nice2see...@gmail.com>wrote: > Its me again. > > I am having a strange problem : > > When I keep a breakpoint in : > > public EventStoreUnitOfWork(IDomainEventStorage<TDomainEvent> > domainEventStorage, IIdentityMap<TDomainEvent> identityMap, IBus bus) > { > _domainEventStorage = domainEventStorage; > _identityMap = identityMap; > _bus = bus; > _eventProviders = new List<IEventProvider<TDomainEvent>>(); > } > > It comes here and also has IDomainEventStorage and IIdentityMap initialized > but when I try to get instance in > another class in same namespace with : > > ServiceLocator.Current.GetInstance(typeof(TransactionHandler<TCommand, > TCommandHandler>)); > > It says dependencies IDomainEventStorage and IIdentityMap are not > registered. > > Any ideas wht's missing? > > I also tried registering : > > container.AddComponent("TransactionHandler", > typeof (TransactionHandler<ICommand, > ICommandHandler<ICommand>>)); > > Still when it tries to get instance of TransactionHandler it says > dependencies IDomainEventStorage and IIdentityMap are not registered. > > I have registered and also got it initialized. What's that I am missing? > > > Pl help. > > > > On Tue, Dec 29, 2009 at 6:26 PM, Bhoomi Kakaiya <nice2see...@gmail.com>wrote: > >> I think Castle Windsor is not detecting the dependency automatically. >> >> TransactionHandler does not implement any interface it is : >> >> public class TransactionHandler<TCommand, TCommandHandler> >> where TCommandHandler : ICommandHandler<TCommand> >> where TCommand : class >> { >> public TransactionHandler(IUnitOfWork unitOfWork) >> {} >> } >> >> As it does not implement any interface I have not registered it. >> CommandHandler is registered. But CommandHandler is a type for this. >> For creating a new instance of TransactionHandler Structuremap was just >> writing : >> >> ObjectFactory.GetInstance<TransactionHandler<TCommand, TCommandHandler>>() >> >> and it was returning the instance of TransactionHandler as its constructor >> was having IUnitOfWork injected. >> >> In castle windsor i have written : >> ServiceLocator.Current.GetInstance<TransactionHandler<TCommand, >> TCommandHandler>>(); >> >> But this throws error. How do i register this then? >> >> >> On Tue, Dec 29, 2009 at 5:07 PM, Bkak <nice2see...@gmail.com> wrote: >> >>> Hi All, >>> >>> I do not know what I am missing, tried various options but nothing >>> seems to work for me. >>> Following is the pseudocode : >>> >>> public interface IDomainEventStorage<TDomainEvent> : >>> ISnapShotStorage<TDomainEvent>, ITransactional where TDomainEvent : >>> IDomainEvent >>> {} >>> >>> public class DomainEventStorage<TDomainEvent> : >>> IDomainEventStorage<TDomainEvent> where TDomainEvent : IDomainEvent >>> { >>> >>> public DomainEventStorage(string sqLiteConnectionString, >>> IFormatter formatter) >>> {} >>> } >>> >>> public class TransactionHandler<TCommand, TCommandHandler> >>> where TCommandHandler : ICommandHandler<TCommand> >>> where TCommand : class >>> { >>> public TransactionHandler(IUnitOfWork unitOfWork) >>> {} >>> } >>> >>> >>> >>> I am converting this from StructureMap to CastleWindsor : >>> Following is Structure Map's syntax used for registration : >>> ForRequestedType<IDomainEventStorage<IDomainEvent>>() >>> >>> .TheDefault.Is.OfConcreteType<DomainEventStorage<IDomainEvent>> >>> () >>> .WithCtorArg("sqLiteConnectionString").EqualTo >>> (sqLiteConnectionString); >>> >>> ForRequestedType<IUnitOfWork>() >>> .TheDefault.Is.ConstructedBy(x => >>> x.GetInstance<IEventStoreUnitOfWork<IDomainEvent>>()); >>> >>> My syntax is : >>> >>> container.Register(Component >>> .For<IDomainEventStorage<IDomainEvent>> >>> () >>> >>> .ImplementedBy<DomainEventStorage<IDomainEvent>> >>> () >>> .LifeStyle.Transient >>> .Parameters(Parameter.ForKey >>> ("sqLiteConnectionString").Eq(sqLiteConnectionString))); >>> >>> container.Register( >>> AllTypes.Of<IUnitOfWork>() >>> .FromAssemblyNamed("ABC").Unless(type => >>> type.IsAbstract) >>> .WithService.FromInterface(typeof >>> (IEventStoreUnitOfWork<IDomainEvent>))); >>> >>> I kept a breakpoint in the constructor it's getting initalized when my >>> web app starts. >>> But when it is required for dependency in : >>> >>> ServiceLocator.Current.GetInstance<TransactionHandler<TCommand, >>> TCommandHandler>>(); >>> >>> it throws this error : >>> {"Activation error occured while trying to get instance of type >>> TransactionHandler`2, key \"\""} >>> >>> {"Can't create component >>> 'Fohjin.DDD.EventStore.Storage.EventStoreUnitOfWork`1' as it has >>> dependencies to be satisfied. >>> Fohjin.DDD.EventStore.Storage.EventStoreUnitOfWork`1 is waiting for >>> the following dependencies: >>> Services: IDomainEventStorage`1 which was not registered. >>> IIdentityMap`1 which was not registered. >>> >>> Both of these services are initialized when my app starts but not when >>> required. >>> >>> What am I missing? >>> >>> Any help would be hightly appreciated. >>> >>> Thanks in advance. >>> >>> Thanks, >>> Bkak. >>> >>> >>> -- >>> >>> You received this message because you are subscribed to the Google Groups >>> "Castle Project Users" group. >>> To post to this group, send email to >>> castle-project-us...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> castle-project-users+unsubscr...@googlegroups.com<castle-project-users%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/castle-project-users?hl=en. >>> >>> >>> >> > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To post to this group, send email to castle-project-users@googlegroups.com > . > To unsubscribe from this group, send email to > castle-project-users+unsubscr...@googlegroups.com<castle-project-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.idcc.co.il - הכנס הקהילתי הראשון למפתחי דוטנט - בואו בהמוניכם -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to castle-project-us...@googlegroups.com. To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.