Windsor IoC Sample Help - “HttpServiceWatcher& which was not registered.”

I'm following the Windsor Inversion of Control (IoC) Getting Started example, which is in C#, but I'm implementing it in VB.Net, and I've run into a small problem..

Here's the exception I'm getting in full:

Can't create component 'form.component' as it has dependencies to be satisfied. form.component is waiting for the following dependencies:

Services: - InversionOfControl.HttpServiceWatcher& which was not registered.

but I think I am registering it - it's the first one registered!

I'm using VB 8 (Visual Studio 2005 / .Net 2.0), and Windsor 1.0 RC3.


Here's my App.vb:

Imports Castle.Windsor

Public Class App

    Public Shared Sub Main()

        Dim container As New WindsorContainer

        'register the components
        container.AddComponent("httpservicewatcher", _
           GetType(HttpServiceWatcher))
        container.AddComponent("email.notifier", GetType(IFailureNotifier), _
           GetType(EmailFailureNotifier))
        container.AddComponent("alarm.notifier", GetType(IFailureNotifier), _
           GetType(AlarmFailureNotifier))
        container.AddComponent("form.component", GetType(Form1))

        'request the component from the container
        Dim aForm As Form = container(GetType(Form1))

        'use it!
        Application.Run(aForm)

        'release it
        container.Release(aForm)

    End Sub

End Class

Form1

Public Class Form1

    Private oServiceWatcher As HttpServiceWatcher

    Sub New(ByRef ServiceWatcher As HttpServiceWatcher)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.oServiceWatcher = ServiceWatcher
    End Sub
End Class

HttpServiceWatcher

Public Class HttpServiceWatcher

    Private oNotifier As IFailureNotifier

    Sub New(ByRef Notifier As IFailureNotifier)
        oNotifier = Notifier
    End Sub

    Sub StartWatching()

        'should start a thread to ping the service
        'if (pingresult = Failed)
        oNotifier.Notify()
        'end if

    End Sub

    Sub StopWatching()

        'stop thread

    End Sub

End Class

IFailureNotifier

Public Interface IFailureNotifier

    Sub Notify()

End Interface

AlarmFailureNotifier and EmailFailureNotifier both implement IFailureNotifier but the Notify() methods are empty


I've tried changing the order by putting the IFailureNotifier's first, HttpServiceWatcher 3rd and Form last but I get the same error.

I've done a Clean and rebuild, but I get the same error.

I'm obviously new to this (as I'm going through the 'Getting Started'), can you point out what I've missed please?

Thank you :o)

Answers


I'm not a VB wiz, but I suspect the problem is the ByRef keyword in the New sub. Try changing it to:

Public Class Form1

    Private oServiceWatcher As HttpServiceWatcher

    Sub New(ServiceWatcher As HttpServiceWatcher)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.oServiceWatcher = ServiceWatcher
    End Sub
End Class

Need Your Help

program exits without error when linking boost library

c++ boost linker arm shared-libraries

I have a problem with linking boost library into my cross-compiled c++ program.

Very simple jQuery overlay

jquery

I'm putting together a fixed, one-page site that deploys an overlay using jQuery. There are two elements that make up the overlay:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.