【问题标题】:Could not load file or assembly kre-clr-win - How can I specify the KRE?无法加载文件或程序集 kre-clr-win - 如何指定 KRE?
【发布时间】:2015-05-24 14:39:54
【问题描述】:

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

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

Exception message: Could not load file or assembly 'file:///C:\inetpub\wwwroot\appname\approot\packages\kre-clr-win-x64.1.0.0-beta3\bin\kre.clr.managed.dll' or one of its dependencies

果然,磁盘上不存在该文件。它从未与我的应用程序一起发布。但是,我确实有 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)

【问题讨论】:

  • 亚马逊盒子上安装K了吗?
  • 我有。虽然它正在寻找一个特定目录作为我的应用程序包的一部分,但它似乎不是系统依赖问题。

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


【解决方案1】:

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

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

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

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

【讨论】:

    猜你喜欢
    • 2015-03-03
    • 1970-01-01
    • 2023-03-02
    • 2020-08-17
    相关资源
    最近更新 更多