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

时间:2015-03-21 04:21:01

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

我正在尝试使用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)

1 个答案:

答案 0 :(得分:2)

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

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

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

这将生成一个包含您的应用程序,其依赖项和CLR的文件夹。只需复制到网络服务器,你应该好好去。