ComponentRegistrationException when registering stubbed dependency in Windsor 3.1

139 views
Skip to first unread message

Scott_M

unread,
Oct 3, 2012, 12:20:23 PM10/3/12
to castle-pro...@googlegroups.com
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?



Patrick Steele

unread,
Oct 3, 2012, 1:33:28 PM10/3/12
to castle-pro...@googlegroups.com
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
> --
> 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 castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to
> castle-project-u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.

Scott_M

unread,
Oct 3, 2012, 2:46:08 PM10/3/12
to castle-pro...@googlegroups.com
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.

Patrick Steele

unread,
Oct 3, 2012, 4:03:28 PM10/3/12
to castle-pro...@googlegroups.com
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


>> > castle-project-u...@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 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 castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to
> castle-project-u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages