ASP.NET Core 1 응용 프로그램을 RC 1에서 RC 2로 마이그레이션합니다. 응용 프로그램에 웹 응용 프로그램 자체 (netcoreapp1.0 대상)와 두 개의 클래스 라이브러리 (.NET Core)가 있습니다. 데이터 액세스 레이어 (netstandard1.5 대상). 이 클래스 라이브러리는 MongoDB 드라이버 2.2.4를 사용합니다. 응용 프로그램은 종속성을 복원하고 오류없이 컴파일합니다. 그러나 MongoDB 클라이언트 초기화 중에 FileNotFound 예외가 발생합니다.MongoDB 드라이버에서 파일을 찾을 수 없음 예외가 발생했습니다.
이 문제를 일으킬 수 있습니다 무엇An exception of type 'System.IO.FileNotFoundException' occurred in MongoDB.Driver.dll but was not handled in user code
Additional information: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
at MongoDB.Driver.MongoUrlBuilder.Parse(String url)
at MongoDB.Driver.MongoUrl..ctor(String url)
at MongoDB.Driver.MongoClient..ctor(String connectionString)
at GS.Quest.DataAccess.Context..ctor() in
CoreWebApp\src\DataAccess\Context.cs:line 9
? 현재 코어 버전의 .NET 용 드라이버를 기다리지 않고 ASP.NET Core RC 2 응용 프로그램 용 레거시 MongoDB 드라이버를 사용할 수 있습니까? 또한 ASP.NET Core RC 1 응용 프로그램에는 문제가 없습니다.
웹 애플리케이션 project.json
{
"userSecretsId": "aspnet-CoreWebApp-6f0c9639-a671-45df-afcb-f126e55c6e3e",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.ApplicationInsights.AspNetCore": "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.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"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.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
"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"
},
"MongoDB.Driver": "2.2.4",
"Models": "1.0.0.*",
"DataAccess": "1.0.0.*"
},
"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"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"dnx451",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
모델 project.json
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027",
"MongoDB.Driver": "2.2.4"
},
"frameworks": {
"netstandard1.5": {
"imports": [ "dnxcore50", "dnx451" ]
}
}
}
마이그레이션하는 동안 DATAACCESS의 project.json
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"MongoDB.Driver": "2.2.4",
"Models": "1.0.0-*"
},
"frameworks": {
"netstandard1.5": {
"imports": [ "dnxcore50", "dnx451" ]
}
}
}
나는 official documentation 다음 한 후 나는 시도 기존 소스 코드를 샘플 ASP.NET Core 1 RC 2 웹 응용 프로그램으로 이동하는 방법 2015 년
UPDATE
다음
웹 응용 프로그램
{
"userSecretsId": "aspnet-CoreWebApp-6f0c9639-a671-45df-afcb-f126e55c6e3e",
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "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.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"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.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
"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"
},
"MongoDB.Driver": "2.2.4",
"Models": "1.0.0.*",
"DataAccess": "1.0.0.*"
},
"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"
]
}
},
"frameworks": {
"net451": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
모델에게 프로젝트 파일을 볼 net451 프레임 워크
{
"version": "1.0.0-*",
"dependencies": {
"MongoDB.Driver": "2.2.4"
},
"frameworks": {
"net451": { }
}
}
DATAACESS를 이동 한 후 비주얼 스튜디오에 의해 생성
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Models": "1.0.0-*"
},
"frameworks": {
"net451": { }
}
}
이 문제를 해결해 주셔서 감사합니다. –
답안의 예가 그 일을하는 올바른 방법입니까 아니면 틀린 답입니까? –
@Son_of_Sam : 질문에서 "Web App project.json"섹션을 발췌 한 것입니다. 그것을하는 잘못된 방법입니다. dnx451은 netcoreapp1.0과 호환되지 않으므로'dnx451'은 거기에 있어서는 안됩니다. 그것은 nuget이 dnx451 패키지를'netcoreapp1.0'에 설치하는 것뿐입니다. – Tseng