C# Visual Studio 2015中的Ninject动态模块加载

C# Visual Studio 2015中的Ninject动态模块加载,c#,testing,visual-studio-2015,ninject,factory,C#,Testing,Visual Studio 2015,Ninject,Factory,我的项目是一个程序集,一个用C#完成的.DLL。我没有前端,所以我只能测试程序而不运行它。这些测试是在另一个项目中的一个类中进行的,我不能修改这个测试类,因为它是由我的教授“按原样”提供的,并且包含在我的评估中。(大学用途) 在我的装配项目中,我有这样一个工厂: public class BugTrackerFactory : IBugTrackerFactory { public void BugTrackerInitialize(IPrincipal principal, strin

我的项目是一个程序集,一个用C#完成的.DLL。我没有前端,所以我只能测试程序而不运行它。这些测试是在另一个项目中的一个类中进行的,我不能修改这个测试类,因为它是由我的教授“按原样”提供的,并且包含在我的评估中。(大学用途)

在我的装配项目中,我有这样一个工厂:

public class BugTrackerFactory : IBugTrackerFactory
{
    public void BugTrackerInitialize(IPrincipal principal, string connectionString)
    {
        //code here
    }

    public IBugTracker LoadBugTracker(IPrincipal principal, string connectionString)
    {
        //code here
    }
}

public class BugModule : NinjectModule
{
    public BugModule() { }

    public override void Load()
    {
        this.Bind<IBugTrackerFactory>().To<BugTrackerFactory>();
    }
}

我真的不知道该怎么办,这里有人能帮我吗?谢谢你

解决了,信不信由你,我没有编译它。。完全忘记了!!无论如何,谢谢您。

IBugTrackerFactory的定义在哪里?试试这个:
kernel.Load(newbugmodule())
(而不是
kernel.Load(Configuration.ImplementationAssembly);
)使用断点或
控制台.WriteLine
查看是否执行了
BugModule.LoadModule
public static class Configuration
{
    public const string ImplementationAssembly =
        @"C:\Users\matte\Documents\Visual Studio 2015\Projects\BugTrackingSystem\BugTrackingSystem\bin\Debug\BugTrackingSystem.dll"; //this is my path to assembly project

}

[TestFixture]
public abstract class TestRoot {
    protected static readonly IBugTrackerFactory Factory;
    .....
    .....
    //all code initializations for testing purpose


    static TestRoot() {
        var kernel = new StandardKernel();
        try {
            kernel.Load(Configuration.ImplementationAssembly);
            Factory = kernel.Get<IBugTrackerFactory>();
        } catch (Exception e) {
            Debug.WriteLine(e);
        }
    }

    ...
    ...
    //all the tests
    One or more child tests had errors
Exception doesn't have a stacktrace

Ninject.ActivationException: Error activating IBugTrackerFactory
No matching bindings are available, and the type is not self-bindable.
Activation path:
  1) Request for IBugTrackerFactory

Suggestions:
  1) Ensure that you have defined a binding for IBugTrackerFactory.
  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.

   in Ninject.KernelBase.Resolve(IRequest request)
   in Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters)
   in BugTrackerTests.TestRoot..cctor() in C:\Users\matte\Documents\Visual Studio 2015\Projects\BugTrackerTests\BugTrackerTests\BasicTests.cs:riga 37