Ninject ActivationException :Ошибка активации IAlertManagement

Я получаю следующую ошибку:

Test method: BootStrapperTest.Can_Create_Alert_Management_Object threw exception:  Ninject.ActivationException: 
Error activating IAlertManagement No matching bindings are available, and the type is not self-bindable. 

Activation path:   
1) Request for IAlertManagement

Suggestions:    
1) Ensure that you have defined a binding for IAlertManagement.    
2) If the binding was defined in a module, ensure that the module has been loaded into the kernel.    
3) Ensure you have not accidentally created more than one kernel.    
4) If you are using constructor arguments, ensure that the parameter name matches the constructors parameter name.    
5) If you are using automatic module loading, ensure the search path and filters are correct.

Вот тестовый пример, который вызывает это исключение:

[TestInitialize]
public void Initialize()
{
    BootStrapper.RegisterTypes();
}

[TestMethod]
public void Can_Create_Alert_Management_Object()
{
    IAlertManagement alertManagementService = BootStrapper.Kernel.Get<IAlertManagement>();

    Assert.IsNotNull(alertManagementService);
}

//This is the code that gets called in [TestInitialize]
public static void RegisterTypes()
{
    if (!initialized)
    {
        Kernel.Bind(scanner => scanner.FromAssembliesMatching("MyCompany.MyProduct.*")
                                  .SelectAllClasses()
                                  .BindDefaultInterface());

        Kernel.Unbind(typeof(IWcfServiceClient<>));
        Kernel.Bind(typeof(IWcfServiceClient<>)).ToMethod(ctx =>
                    (ctx.Kernel.Get(typeof(WcfServiceClientProvider<>).MakeGenericType(ctx.GenericArguments)) as IProvider).Create(ctx)); 
    }

    initialized = true;
}

Вышеупомянутая ошибка возникает в одном из моих модульных тестов на нашем сервере сборки , но не на моей машине разработки. У меня есть 7 других тестов, почти идентичных этому, которые проходят на сервере сборки и на моей машине для разработки, но это единственный тест, который не проходит.

Интерфейс IAlertManagement исходит из dll с именем Core , а конкретный тип исходит из другой dll с именем AlertManagement . У меня есть dll Core и dll AlertManagement , включенные в мой проект модульного тестирования в качестве ссылок на проект. У меня есть 7 или 8 других тестов, идентичных этой ситуации, но это единственный тест.

Любые идеи будут признательны.

9
задан Cole W 8 August 2012 в 12:13
поделиться