asp.net - 无法加载文件或程序集 kre-clr-win - 如何指定 KRE?

标签 asp.net iis clr asp.net-core asp.net-core-mvc

我正在尝试在 Visual Studio 2015 CTP 中使用 ASP.NET 5 构建我的第一个应用程序。我刚刚将应用程序发布到文件系统,并将文件夹复制到我的 AWS EC2 实例。我在 IIS 中设置了该应用程序,因此它指向我发布的应用程序中的 wwwroot 目录。

尝试运行该应用程序时,我不断收到蓝屏死机 (YSOD)。查看事件查看器,我可以看到抛出了未处理的异常:

异常消息:无法加载文件或程序集“file:///C:\inetpub\wwwroot\appname\approot\packages\kre-clr-win-x64.1.0.0-beta3\bin\” kre.clr.managed.dll' 或其依赖项之一

果然,磁盘上不存在该文件。它从未与我的申请一起发布。不过,我有 x86 版本:kre-clr-win-x86.1.0.0-beta3。该目录是与我的应用程序一起发布的。

由于某种原因,我的应用程序是使用 kre-clr-win-x86 发布的,但是当我尝试运行已发布的应用程序时,它正在寻找 kre-clr-win-x64。如何解决这个问题?

编辑

这是在发布的 wwwroot 文件夹中生成的 web.config:

<configuration>
  <appSettings>
    <add key="kpm-package-path" value="..\approot\packages" />
    <add key="bootstrapper-version" value="1.0.0-beta3" />
    <add key="runtime-path" value="..\approot\packages" />
    <add key="kre-version" value="1.0.0-beta3" />
    <add key="kre-clr" value="clr" />
    <add key="kre-app-base" value="..\approot\src\appname" />
  </appSettings>
</configuration>

编辑2

作为发布的一部分,生成了一个 web.cmd 文件(尽管我不确定该文件的特定用例是什么),如果我运行它,该应用程序将在 localhost:5000 上提供服务。如果我在本地访问该页面,它就可以工作。那么这可能与 IIS 管道有关?

这是完整的堆栈跟踪:

Exception information: 
    Exception type: FileNotFoundException 
    Exception message: Could not load file or assembly 'file:///C:\inetpub\wwwroot\Gastropub\approot\packages\kre-clr-win-x64.1.0.0-beta3\bin\kre.clr.managed.dll' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)    at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)    at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)    at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)    at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)    at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)    at AspNet.Loader.Bootstrapper.InitializeNet45(String runtimePackagePath, AppDomain targetDomain, String packagesDir, IObjectHandle& handle, String[]& args)    at AspNet.Loader.Bootstrapper.LoadApplicationNet45(String appId, String appConfigPath, IProcessHostSupportFunctions supportFunctions, LoadApplicationData* pLoadAppData, Int32 loadAppDataSize, String runtimePackagePath, String appBasePath)    at AspNet.Loader.Bootstrapper.LoadApplication(String appId, String appConfigPath, IProcessHostSupportFunctions supportFunctions, LoadApplicationData* pLoadAppData, Int32 loadAppDataSize)    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)    at System.Web.Hosting.ProcessHost.System.Web.Hosting.IProcessHostLite.ReportCustomLoaderError(String appId, Int32 hr, AppDomain newlyCreatedAppDomain)
--- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)   at System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException)

最佳答案

如果您在 64 位操作系统上部署应用程序,则需要使用 64 位 KLR。

这是将应用程序与 KLR 捆绑在一起的方式:

kpm bundle --runtime kre-clr-win-x64.1.0.0-beta3

这将生成一个文件夹,其中包含您的应用程序、其依赖项和 CLR。只需复制到网络服务器就可以了。

关于asp.net - 无法加载文件或程序集 kre-clr-win - 如何指定 KRE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29179213/

相关文章:

c# - IIS 7.5 访问数据库时失败

ASP.Net - 在没有 Windows 用户的情况下使用基本身份验证

c# - 使用 ICorDebugEval 的通用类型 func-eval

sql-server-2008 - SQL CLR、HttpWebRequest 和连接限制

ASP.net Vb.Net Label.Text 不更新

asp.net - MultipartFileStreamProvider 能否有效保存文件上传?

asp.net - ASP-获取 GridRow 值/OnClick 方法

asp.net - Azure 上托管的 MVC 4 网站显示我无权查看目录或页面

asp.net - 编译 ASP.NET 应用程序 - 网站与 Web 应用程序 - 具有指定 dll 名称的占位符 aspx 文件

c# - 编译错误CS0305 使用泛型类型List