Asp.Net vNext クラス ライブラリで Ninject を使用したいと考えています。しかし、コンパイラ エラー CS0246 (「型または名前空間名 'Ninject' が見つかりませんでした」) が発生します。
これが私がやったことです:
1) 新規作成ASP.NET vNext Class Library
2) 編集project.json
:
{
"dependencies": {
"Ninject": "3.2.2.0"
},
"configurations" : {
"net451" : {
"dependencies": {
}
},
"k10" : {
"dependencies": {
"System.Runtime": "4.0.20.0"
}
}
}
}
3) パッケージ マネージャーのログを確認します。
Restoring packages for C:\Projects\ClassLib1\project.json
Attempting to resolve dependency ClassLib1 >= 1.0.0
Attempting to resolve dependency Ninject >= 3.2.2.0
GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Ninject'
Attempting to resolve dependency mscorlib >=
Attempting to resolve dependency System >=
Attempting to resolve dependency System.Core >=
Attempting to resolve dependency Microsoft.CSharp >=
Attempting to resolve dependency ClassLib1 >= 1.0.0
Attempting to resolve dependency Ninject >= 3.2.2.0
Attempting to resolve dependency System.Runtime >= 4.0.20.0
OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Ninject' 1250ms
GET https://www.nuget.org/api/v2/FindPackagesById?id='Ninject'&$skiptoken='Ninject','3.0.2-unstable-9057'
OK https://www.nuget.org/api/v2/FindPackagesById?id='Ninject'&$skiptoken='Ninject','3.0.2-unstable-9057' 179ms
GET https://www.nuget.org/api/v2/package/Ninject/3.2.2
OK https://www.nuget.org/api/v2/package/Ninject/3.2.2 949ms
Resolving complete, 2531ms elapsed
Installing Ninject 3.2.2.0
Restore complete, 2755ms elapsed
元気そう..
4) 編集Class1.cs
:
using Ninject;
namespace ClassLib1
{
public class Class1
{
public Class1()
{
var kernel = new StandardKernel();
}
}
}
Intellisense は Ninject への参照を解決できます。
5) ビルドして、CS0246 を取得しました。
1>------ Build started: Project: ClassLib1, Configuration: Debug Any CPU ------
1> Building ClassLib1 .NETFramework,Version=v4.5.1
1> Building ClassLib1 K,Version=v1.0
1>C:\Projects\ClassLib1\Class1.cs(1,7): error CS0246: The type or namespace name 'Ninject' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Projects\ClassLib1\Class1.cs(9,30): error CS0246: The type or namespace name 'StandardKernel' could not be found (are you missing a using directive or an assembly reference?)
1>
1> Build failed.
1> 0 Warnings(s)
1> 2 Error(s)
どうしたの?