For something lighter than Rhino.Mocks, you might want to try DynamicProxy (which is what Rhino.Mocks uses under the covers). It should get you the ability to dynamically create an instance of a particular interface/non-sealed class and use it instead of a real class.
Although I'd be curious to see if the Dynamic Proxy one works since that what Rhino.Mocks is using as well... --- Patrick Steele http://weblogs.asp.net/psteele On Wed, Oct 3, 2012 at 2:46 PM, Scott_M <[email protected]> wrote: > Making a real .net class that does nothing seems to register without > problem. Not sure why the rhinomock stub would not register. Would be > handy as we have a couple of other service dependencies that don't always > get used and would be nice to inject stubs. > > > > On Wednesday, October 3, 2012 12:33:32 PM UTC-5, Patrick Steele wrote: >> >> What if you forget about the overhead of Rhino.Mocks and just create a >> real .NET class: >> >> public class ServiceStub : IRasterImageService >> { >> .... >> } >> >> Do you get the same error? >> >> --- >> Patrick Steele >> http://weblogs.asp.net/psteele >> >> >> On Wed, Oct 3, 2012 at 12:20 PM, Scott_M >> <[email protected]> wrote: >> > Using Windsor 3.1 in VS2012. I have a master installer class that >> > registers >> > all my service dependencies. One of the required dependencies is not >> > used/needed in the particular solution so I attempted to stub it and >> > register the stub (Rhinomocks) like so: >> > >> > >> > IRasterImageService fakeRasterSvc = >> > MockRepository.GenerateStub<IRasterImageService>(); >> > >> > >> > container.Kernel.AddComponentInstance<IRasterImageService>(fakeRasterSvc); >> > >> > This results in the following error: >> > "IRasterImageService could not be registered. There is already a >> > component >> > with that name. Did you want to modify the existing component instead? >> > If >> > not, make sure you specify a unique name." >> > >> > The odd thing is that nowhere else is this component registered. I can >> > comment out that code and get an error saying that IRasterImageService >> > was >> > not registered. >> > What am I doing wrong? >> > >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "Castle Project Users" group. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/castle-project-users/-/Jxxbf_4nlG8J. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > 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 view this discussion on the web visit > https://groups.google.com/d/msg/castle-project-users/-/UilZdVwoHJIJ. > > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
