我正在使用VS2015將ASP.NET 5應用程序部署到Azure。在成功部署並在瀏覽器中打開我的網站後,我收到錯誤:ASP.NET 5/Azure錯誤:FileNotFoundException:無法加載文件或程序集System.Data.SqlClient
FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
該程序集未在我的項目中直接引用。它是通過EntityFramework.MicrosoftSqlServer程序集間接依賴的。
我有類似的問題使用ASP.NET 4在這裏解釋:Error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient' 解決方案名爲「可怕的黑客」然後爲我工作。 :)
你有什麼想法可能會導致這個問題,以及如何解決它?
這裏是我的web應用程序project.json的內容:
{
"userSecretsId": "aspnet5-MyProject.Web-<A guid goes here>",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.Framework.CommandLineUtils.Sources": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"MyProject.Data": "1.0.0-*",
"System.Data.SqlClient": "4.0.0-beta-23516" <-- I've tried with this explicit dependency here
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
和MyProject.Web是取決於該MyProject.Data項目project.json:
{
"version": "1.0.0-*",
"description": "MyProject.Data Class Library",
"authors": [ "f012rt" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"commands": {
"ef": "EntityFramework.Commands"
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516",
"System.Data.SqlClient": "4.0.0-beta-23516" <-- I've tried with this explicit dependency here
}
}
我已經試過明確指定缺少的依賴項,正如你可以從我的project.json文件中看到的那樣。我可以確認包「System.Data.SqlClient」:「4.0.0-beta-23516」位於我的[approot] \ packages文件夾中。包文件夾在我的本地計算機上看起來完全如此。我已經嘗試在新創建的Web App上進行部署,以避免由於舊版本引起的任何問題。錯誤仍然是一樣的。
這可能是最清晰的可執行文件m –
您可以發佈您的project.json文件的內容嗎? – MrDustpan