【问题标题】:ASP.NET 5 (ASP.NET Core) - unable to run with IISASP.NET 5 (ASP.NET Core) - 无法使用 IIS 运行
【发布时间】:2016-02-06 23:35:33
【问题描述】:

我正在尝试将我的 ASP.NET 5 MVC 项目部署到本地 IIS,但遇到了一些错误。

错误

打开时(我的网站地址)localhost:80 我有 HTTP 404。如果我手动运行approot\web.cmd,我将面临同样的行为。我认为问题是一样的。在web.cmd 控制台中,我看到每个请求的输出(对于非静态路由,静态文件效果很好):

fail: Microsoft.Data.Entity.Query.Internal.SqlServerQueryCompilationContextFactory[1]
  An exception occurred in the database while iterating the results of a query.
  System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. File not found.
  File name: 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load the specified file.
  File name: 'System.Data.SqlClient'
     at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
     at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
     at Microsoft.Data.Entity.Storage.Internal.SqlServerConnection.CreateDbConnection()
     at Microsoft.Data.Entity.Internal.LazyRef`1.get_Value()
     at Microsoft.Data.Entity.Storage.RelationalConnection.Open()
     at Microsoft.Data.Entity.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
     at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
     at Microsoft.Data.Entity.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()

问题

当我从我的项目开发目录MySolution\src\MyProject运行dnx web时一切正常

我的项目.json

您可以看到我使用的是dnxcore50,并且没有依赖于System.Data.SqlClient。

{
"userSecretsId": "aspnet5-Stomatology-b7dc4859-6376-4a5f-a583-d17b3660a64c",
"version": "1.0.0-*",
"compilationOptions": {
    "emitEntryPoint": true
},

"dependencies": {
    "AutoMapper": "4.1.1",
    "Domain": "1.0.0-*",
    "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.Server.WebListener": "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.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},

"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
},

"frameworks": {
"dnxcore50": { }
},

"exclude": [
    "wwwroot",
    "node_modules"
],
"publishExclude": [
    "**.user",
    "**.vspscc"
],
"scripts": {
    "prepublish": [ "npm install", "bower install" ]
}

}

我的部署和 IIS 设置

  1. 我使用 File System 选项进行部署,就像在 manauls 中一样
  2. 我安装了 HTTP 平台处理程序
  3. 我使用了没有管理环境的应用程序池

结论

那么,有什么办法可以解决这个问题吗?

【问题讨论】:

  • dnx 不要复制所有引用的 dll,将该 dll 从我们的框架复制到部署的 bin 文件夹。
  • @Gusman,我会试试的。但是为什么我需要System.Data.Entity,如果我使用EF7,它不依赖于System.Data*,但依赖于Microsoft.Data.*?
  • P.S. bin 你是说myapp\approot\runtimes\myruntime\bin?

标签: c# asp.net iis asp.net-core


【解决方案1】:

我让它工作了。以下是我为使其工作而采取的步骤:

  1. 请求的页面无法访问,因为该页面的相关配置数据无效。

    • 安装 HTTP 平台处理程序
    • 确保在 Windows 组件中启用了 ASP.NET 4.6:Internet 信息服务 -> 全球服务 -> 应用程序开发组件 -> ASP.NET 4.6
  2. 无法加载System.Data.SqlClient

    • 将System.Data.SqlClient 添加到您的project.json
  3. 无法加载sni.dll

    • 在 x64 操作系统上使用 x64 coreclr 运行时。
    • 安装 MS VC++ 2012 可再发行组件

如果它仍然不起作用... (在今天 08.02.2016 中使用 1.0.0-rc1-update1 为我提供帮助): - 删除所有 dnx 运行时 - 在 Visual Studio 中安装 ASP.NET 和 Web 工具的最新更新 - 在部署设置中设置 VS 中最新的 x64 运行时

我想,这是某种魔法,我不知道为什么会这样。

【讨论】:

  • 有机会用英文的截图代替吗?如果不是 - 请删除它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 1970-01-01
  • 2016-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-01
相关资源
最近更新 更多