Ninject and MonoDroid

Is anyone lucky that Ninject is working on MonoDroid? I tried versions 2.0 and 4.0 from your site, and also tried .net versions.

With Mono builds, I get a MissingMethodException in creating my standard kernel

+1
source share
2 answers

I am experimenting with Ninject in a WP7 / Monotouch / Mono combined project for Android, and Ninject works surprisingly well.

I used the latest sources that contain the Ninject.WP7.csproj project file, which seems to be out of date. It contains many DefineConstants. I created new WP7 / Monotouch / Mono solutions for Android with these constants, and everything compiled and works!

Constants Used:

SILVERLIGHT,SILVERLIGHT_40,NO_LCG,NO_ASSEMBLY_SCANNING,NO_WEB,NO_PARTIAL_TRUST,NO_SKIP_VISIBILITY,NO_EXCEPTION_SERIALIZATION,NO_DEBUG_SYMBOLS 

not sure if they are all needed, but SILVERLIGHT is important because Monotouch / Mono for Android implements most of the Silverlight api.

Of course, you cannot create Android applications using Ninject. I use it mainly to install the constructor, to create .Net objects such as ViewManager, view models using the repository, etc., The usual things you do with dependency injection.

+5
source

I did not try to get Ninject to work, but I would be very surprised if it just worked out of the box. If there is a Silverlight build of Ninject, you might be lucky with this, but there are no guarantees. The β€œbest” way to get support in Mono for Android is to create code with a Mono profile for Android as a class library.

However, there are other options for hosting services in your applications. I have a blog post here that talks about using TinyIoC and Funq for location services.

+1
source

All Articles