EventBroker: Unable to register event subscriber.

19 views
Skip to first unread message

Telavian

unread,
Jun 18, 2012, 7:26:44 PM6/18/12
to bbvc...@googlegroups.com
I asked this same question on StackOverflow here, but wasn't sure if this is a better place.

I am attempting to use bbv.common.EventBroker with Ninject and am running into a few problems getting things wired up correctly.

I currently am using Ninject factories to create an item and then, since I subscribe to events, use the eventbroker to do the subscription. However when the register method is called I get an error that I can not find any information for at all. I am not even sure what the error means.

**Error:**

   bbv.Common.EventBroker.Exceptions.RepeatedSubscriptionException occurred
  Message=Cannot add more than one subscription handler method of the same subscriber one topic: 'Method1'.
  Source=bbv.Common.EventBroker
  StackTrace:
       at bbv.Common.EventBroker.Internals.EventTopic.ThrowIfRepeatedSubscription(Object subscriber, String handlerMethodName)
       at bbv.Common.EventBroker.Internals.EventTopic.AddSubscription(Object subscriber, MethodInfo handlerMethod, IHandler handler, IList`1 subscriptionMatchers)
       at bbv.Common.EventBroker.Internals.EventInspector.HandleSubscriber(Object subscriber, Boolean register, MethodInfo methodInfo, EventSubscriptionAttribute attr, IEventTopicHost eventTopicHost)
       at bbv.Common.EventBroker.Internals.EventInspector.ProcessSubscriber(Object subscriber, Boolean register, IEventTopicHost eventTopicHost)
       at bbv.Common.EventBroker.EventBroker.Register(Object item)      
  InnerException:



**Code:**

    public const string Topic1 = "Topic1";
    public const string Topic2 = "Topic2";
    public const string Topic3 = "Topic3";
    public const string Topic4 = "Topic4";

    public ItemHelper(IItem item, IEventBroker eventBroker)
    {
      _item = item;
      eventBroker.Register(this);
    }

    [EventSubscription(Topic1, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
    public void Method1(object sender, SomeArgs1 args)
    {
      ...
    }

    [EventSubscription(Topic2, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
    public void Method2(object sender, SomeArgs2 args)
    {
      ...
    }

    [EventSubscription(Topic3, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
    public void Method3(object sender, SomeArgs3 args)
    {
      ...
    }

    [EventSubscription(Topic4, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
    public void Method4(object sender, SomeArgs4 args)
    {
      ...
    }


Urs Enzler

unread,
Jun 19, 2012, 2:56:54 AM6/19/12
to bbvc...@googlegroups.com
Hi

This exception is typically thrown when the same instance is registered twice. Make sure that the object you created is only registered once on the event broker.

In the code you posted is no error (at least I cannot spot any).

Let me know if this helps.

Happy coding
Urs

Telavian

unread,
Jun 19, 2012, 11:19:37 AM6/19/12
to bbvc...@googlegroups.com
I didn't notice it before, but the interface for the class also had the method attribute on it. Thus it was declared twice. However, I didn't see it until I looked at the interface.
Thanks.
Reply all
Reply to author
Forward
0 new messages