[Solved] Ninject ‘System.Runtime.CompilerServices.ExtensionAttribute’ is defined in multiple assemblies

Ninject Bug with .net framework 3.5

If you getting this error with your application that using ninject dependency injector.

System.Runtime.CompilerServices.ExtensionAttribute’ is defined in multiple assemblies in the global alias; using definition from  [….]\Ninject.Core.dll
Or
Missing compiler required member ‘System.Runtime.CompilerServices.ExtensionAttribute..ctor’

This is a know bug with ninject.NET 2.0 build would work for .NET 3.5 as well, but the extension method patch will screw things up.
http://bugs.ninject.org/jira/browse/NINJECT-4

Solution is:

 You can solve it by yourself

1)  Download source , extrat it some folder and open with VS IDE.
http://ninject.org/assets/dist/Ninject-1.0-src.zip

2) There are two project   “Core” and “Tests” that we change .

3) Open project properties windows by click solution explorer-> Core (Right Click ) -> Properties

4)Click “Application” Tab on the left side

5) Select  “.NET 3.5 framework ” in Target Framework combobox. 

6) Click  “Build” Tab on the left side

7)  type “NET_35” in Conditional Compilation Symbol box (Preprocessor flag)

8) Do it same with “Tests” Project

9) Rebuild solution.

Its worked for me 🙂

Advertisement