1

I'm using ninject xml extension to congire different DAL's for the same executable (plugins). My idea was to put all of them (DLLs) in a subfolder of the main application with the ninject xml files.

The problem is that ninject cannot find the referenced binding in the xml. It works only if i copy the dlls to the same folder of the main application (.exe).

I tried to load the dlls before loading the kernel

Assembly assembly = Assembly.LoadFrom(dll);
AppDomain.CurrentDomain.Load(assembly.GetName());
Kernel.Load(xmlFile);

But still doesnt work. (Error: "Couldnt resolve type 'MyType' defined in 'to' attribute")

Does anybody know some way to refer a concrete folder at the ninject-xml file or loading types from another folder that can be resolved using ninject-xml extension?

Morvader
  • 2,317
  • 3
  • 31
  • 44

2 Answers2

0

Would the conventions extension perhaps solve the problem by loading your bindings based on what DLLs are present? If not, can you please explain your problem with some more detail?

Ian Davis
  • 3,848
  • 1
  • 24
  • 30
  • It seems that Ninject cannot resolve types when they are declared in a dll placed in a subfolder (./Plugins/MyType.dll). It works fine when the dll its placed at the main folder. Note that in both cases the dlls are not referenced from the main project, the idea is to load them dynamically – Morvader Nov 16 '12 at 09:34
  • 2
    Custom folders are not part of the .NET assembly resolution look up: http://stackoverflow.com/questions/4145728/what-is-the-net-folder-search-hierarchy - Also, you still haven't said what the actual error is. Saying it "still does not work" tells us nothing of the error(s) you have encountered. Perhaps if you used the xml to specify which libraries to load, and used the conventions extension to select from those assemblies and create the bindings, you might have something that solves your issue. – Ian Davis Nov 19 '12 at 04:26
  • The problem was that ninject couldnt resolve the binding specified at xml: "Couldnt resolver type MyType defined in 'to' attribute". Anyway, thanks for the link to resolution look up, I solved my problem adding the "probing" element to the config. if you want to write it as an answer I will accept it. Thanks!. – Morvader Nov 19 '12 at 09:14
  • What is the probing element? I don't quite follow what you did to solve the issue. – Ian Davis Nov 21 '12 at 18:43
0

I solve this usign the "probing" element at the config file. It includes a folder at the resolution scope.

<runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="Plugins"/>
      </assemblyBinding>
 </runtime>

More info here.

Thanks to all.

Morvader
  • 2,317
  • 3
  • 31
  • 44