I have a web project using ASP.NET Core RC2 and dotnet CLI, targeting the .NET Framework, just updated from ASP.NET 5 RC1 and DNX. As soon as I use the distributed SQL Server cache, it crashes with the following exception:
FileNotFoundException: Could not load file or assembly 'System.Collections.NonGeneric, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
with the stack trace:
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) System.Data.SqlClient.SqlConnection..ctor(String connectionString) Microsoft.Extensions.Caching.SqlServer.DatabaseOperations.GetCacheItem(String key, Boolean includeValue) Microsoft.Extensions.Caching.SqlServer.DatabaseOperations.GetCacheItem(String key) Microsoft.Extensions.Caching.SqlServer.SqlServerCache.Get(String key) Microsoft.AspNetCore.Session.DistributedSession.Load() Microsoft.AspNetCore.Session.DistributedSession.Remove(String key) MYCODE.SessionHelper.SetValue(String key, String value) in MYCODE.cs, etc
The line is literally just Session.Remove(key);
.
I am suspecting that it is trying to load .NET Core packages for some reason instead of realizing that it can use the .NET Framework. Below is my project.json.
{
"webroot": "wwwroot",
"userSecretsId": "aspnet5-MYCODE-2d5ac1d3-01c8-4be2-9be2-894efd942480",
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": false,
"gcConcurrent": true
},
"dependencies": {
//"Microsoft.NETCore.Platforms": "1.0.1-rc2-24027",
//"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"MYOTHERCODE": "1.0.0-*",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Abstractions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final",
"Microsoft.Extensions.Options": "1.0.0-rc2-final",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"System.Text.Encodings.Web": "4.0.0-rc2-24027",
"Newtonsoft.Json.Schema": "2.0.2",
"OtpSharp": "1.3.0.4",
"Microsoft.AspNetCore.Session": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor": "1.0.0-rc2-final",
"Microsoft.Extensions.Caching.SqlServer": "1.0.0-rc2-final",
"Microsoft.CodeAnalysis.CSharp": "1.3.0-beta1-20160429-01",
"Microsoft.CodeAnalysis.Workspaces.Common": "1.3.0-beta1-20160429-01",
"Newtonsoft.Json": "8.0.3",
"Twilio": "4.7.1"
},
"frameworks": {
"net46": {
"imports": [ "dnx451" ],
"frameworkAssemblies": {
"System.Runtime.Serialization": "4.0.0.0"
}
}
},
"runtimes": {
"win7-x64": {}
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
"Microsoft.Extensions.SecretManager.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"appsettings.*.json",
"web.config"
]
}
}
Adding entries for Microsoft.NETCore.Platforms
(1.0.1-rc2-24027
) and/or NETStandard.Library
(1.5.0-rc2-24027
) in dependencies
has not helped. Since the documentation describing how to do this is lacking to nonexistent, I am probably doing something wrong in targeting .NET Framework. The only question is what? Am I missing an import or a reference assembly or something?