appharbor WCF服务程序集由比当前加载的运行时更新的运行时构建,无法加载

时间:2013-08-05 21:56:49

标签: c# .net wcf c#-4.0 appharbor

当我尝试在appharbor中运行我的WCF服务时出现以下错误。我在本地计算机上使用.NET Framework 4并且它有效。我在appharbor中禁用了预编译,因此在部署期间它不会产生任何错误。因此,构建成功部署没有任何错误。

  

' /'中的服务器错误应用

     

无法加载文件或程序集' TnPServiceAH'或其中一个依赖项。此程序集由比当前加载的运行时更新的运行时构建,无法加载。

     

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

     

异常详细信息:System.BadImageFormatException:无法加载文件或程序集' TnPServiceAH'或其中一个依赖项。此程序集由比当前加载的运行时更新的运行时构建,无法加载。

     

来源错误:

     
    

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

  
     

装配加载跟踪:以下信息有助于确定装配' TnPServiceAH'无法加载。

     
    

警告:装配绑定日志记录已关闭。     要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1。     注意:程序集绑定失败日志记录会导致一些性能损失。     要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog]。

  
     

堆栈追踪:

     
    

[BadImageFormatException:无法加载文件或程序集' TnPServiceAH'或其中一个依赖项。此程序集由比当前加载的运行时更新的运行时构建,无法加载。        System.Reflection.Assembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,Assembly locationHint,StackCrawlMark& stackMark,Boolean throwOnFileNotFound,Boolean forIntrospection)+0        System.Reflection.Assembly.nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,Assembly locationHint,StackCrawlMark& stackMark,Boolean throwOnFileNotFound,Boolean forIntrospection)+48        System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)+278        System.Reflection.Assembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)+145        System.Reflection.Assembly.Load(String assemblyString)+28        System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+46

         

[ConfigurationErrorsException:无法加载文件或程序集' TnPServiceAH'或其中一个依赖项。此程序集由比当前加载的运行时更新的运行时构建,无法加载。        System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+590        System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+193        System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)+45        System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+178        System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir)+164        System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir,Boolean ignoreErrors)+51        System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir,VirtualPath virtualDir,Boolean ignoreErrors)+187        System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)+648        System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath,Boolean noBuild,Boolean allowCrossApp,Boolean allowBuildInPrecompile)+305        System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context,VirtualPath virtualPath,Boolean noBuild,Boolean allowCrossApp,Boolean allowBuildInPrecompile)+99        System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context,VirtualPath virtualPath,Boolean noBuild,Boolean allowCrossApp,Boolean allowBuildInPrecompile)+75        System.Web.Compilation.BuildManager.GetCompiledCustomString(String virtualPath)+28        System.ServiceModel.HostingManager.GetCompiledCustomString(String normalizedVirtualPath)+135        System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath)+26        System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath)+43        System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)+495

         

[ServiceActivationException:服务' /TnPServiceAH.svc'由于编译期间的异常,无法激活。异常消息是:无法加载文件或程序集' TnPServiceAH'或其中一个依赖项。此程序集由比当前加载的运行时更新的运行时构建,无法加载..]        System.ServiceModel.AsyncResult.End(IAsyncResult result)+394        System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)+196        System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context,Boolean flowContext)+216        System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender,EventArgs e)+271        System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+128        System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)+168

  
     

版本信息:Microsoft .NET Framework版本:2.0.50727.5472; ASP.NET版本:2.0.50727.5471

2 个答案:

答案 0 :(得分:2)

我通过App Harbor Support得到了答案。 App Harbor通过“targetFramework”属性的存在和值检测ASP.NET 4.0,因此配置文件(web.config)应包含以下内容:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>

答案 1 :(得分:1)

看起来您在部署到的计算机上的IIS下的网站配置中设置了错误的ASP.Net版本。打开IIS管理器并确保为该应用程序配置的ASP.Net版本为4.0。在较旧的Windows版本中,您可以在每个应用程序中设置更新版本(我认为是2008及以上版本),它是按照应用程序池完成的。