3

I am looking for an IoC container that scans all types in all assemblies within the bin folder AND is compatible with mono.

I used to use LightCore, which took a little configuration to declare the implementation of a specific interface, and then automagically resolves it, but it doesn't seem to be compatible with mono...

I have tried TinyIoC too, but that one only scans types within referenced assemblies, and my problem is that the assembly that contains the implementation cannot be referenced by my other project that needs to resolve it (circular reference issue).

Background (only read if you want to understand why I have this circular ref issue):

In my solution I have 2 projects, the main one, that contains my entities and business logic, and the second one that contains the data access stuff.

I want to do it this way, because I have had to change DB system several times before, porting the app from MSSQL to PostgreSQL for example. So my main assembly contains several things:

  • Entities, actual objects I work with in my business logic within the same assembly,

  • A contract for the storage context that describes how it should be implemented: it should contain beginTransaction, commit, rollback methods,

  • A contract for the generic repository, that says it should implement a method to get a single record, a list etc...

My second assembly only contains the implementation of the contracts, and takes care of accessing the data store.

The result is that my second assembly needs a reference to my main assembly to know about the types it'll have to work with. Doing this means my main assembly cannot have a reference to the data access one as that would cause the circular ref issue.

I have been using LightCore to resolve the implementation of my contracts and it works just fine, however, LightCore references things such as the PresentationFramework, and mono doesn't seem to like it. And this is why I am now looking for an IoC container that would do the same as LightCore (scan folder and not referenced assemblies) and that is compatible with mono.

Thanks! :)

2

http://www.ninject.org/download.html is specified to support Mono2.0 and 4.0, at least ninject 3.0. You'd have to try out 3.2.

With ninject.extensions.conventions you can scan assemblies as you like. You can specify filter (path, name,... ) or you pass it a path to all assemblies it should scan.

Example usage: https://github.com/ninject/ninject.extensions.conventions/wiki/Overview

kernel.Bind( x => x
  .FromThisAssembly()
  // .IncludingNonePublicTypes()
  .SelectAllClasses()
  .BindAllInterfaces()
  .Configure(b => b.InSingletonScope()));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.