views:

188

answers:

1

I'm building a Silverlight application with Prism, and we'd like to use NInject. I've downloaded ninject-contrib to use their NInject bootstrapper, but it doesn't appear to build a Silverlight assembly. I compiled it myself to Silverlight, but it crashes Visual Studio.

Has anyone already ported ninject-contrib to Silverlight successfully?

+1  A: 

You shouldn't have to use ninject-contrib. There is a download available for Silverlight. You can find it here. Let me know if this isn't what you are looking for, but if you would just like to use Ninject for dependency injection in a Silverlight app, this should be all you need.

J.R. Garcia
Looking back at my original question, I did a poor job of specifying what I was looking for. Prism applications, whether built for WPF or Silverlight, typically contain a class that bootstraps the application using the particular IoC container. Ninject-contrib contains a Prism bootstrapper that leverages NInject. I was attempting to use this bootstrapper, but I found that the Visual Studio solution did not contain a project file that targeted Silverlight...
pnschofield
What I ended up doing was importing the source code into a Silverlight class library project and making a few small changes to get it to compile.Next I wrote a few unit tests using a version of NUnit 2.5.1 ported to Silverlight 3: http://wesmcclure.tumblr.com/post/152727000 When I used TestDriven.NET to run unit tests that exercised the bootstrapper, Visual Studio 2008 crashed.
pnschofield
Since using this combination of tools together (including my own untested "port" of ninject-contrib to SL3) was a very large hack, I probably should have considered an alternate solution before posting to StackOverflow.What I've ended up doing is to stop using the bootstrapper altogether in unit tests, which is probably a good idea anyway, as you probably don't want your unit tests to be coupled to your application bootstrapping anyway.
pnschofield