1

I am trying to inject from another class library but it doesn't work, i am getting this error: Couldn't resolve type 'BLL.UserBLL, MyProject.Core' defined in 'to' attribute.

XML:

<module name="MyModule">
  <bind service="IUserBLL, MyWebProject"
        to="BLL.UserBLL, MyProject.Core" name="UserBLL" />
</module>

So i am trying to use the class UserBLL in the namespace "BLL" in the external class library "MyProject.Core".

The MyProject.Core is refered in MyWebProject

What am i doing wrong?

  • is the the MyProject.Core dll present in the MyWebProject output directory ? If not, try to copy the dll in the output directory to see if it changes something – jbl Oct 20 '17 at 20:19
  • Yes it is present in the output directory. – Victor Öhrström Oct 21 '17 at 12:40
  • the "to" attribute handling is done here. https://github.com/ninject/Ninject.Extensions.Xml/blob/master/src/Ninject.Extensions.Xml/Processors/BindingBuilderFactory.cs#L76 You may try to see the result of a `Type.GetType("BLL.UserBLL, MyProject.Core")` in your MyWebProject code to see if your own app is able to load the library. Also, is the MyProject.Core in the same platform and .net version target as your MyWebProject ? – jbl Oct 24 '17 at 10:23
  • Everything seems good and if i change the XML file to have a class that doesn't exist it throuws an exception so it might work BUT when i try to inject it into a webservice (asmx) i get null for the instance. – Victor Öhrström Nov 07 '17 at 14:17
  • It still doesn't work. A extra note is that i can see the binding of i debug and inspect the kernel so the mapping is made correctly. I try to inject into a webservice (asmx), i've changed the inheritance to Ninject.Web.WebServiceBase and i am putting the attribute [Inject] to the property that i want to inject. All this works if i use kernel.Bind() instead with the same class and interface. – Victor Öhrström Nov 08 '17 at 10:01

0 Answers0