我想在AppHarbor上託管一個ServiceStack Razor網站。該網站建立,但是當我導航到該網站時,我得到以下錯誤AppHarbor ServiceStack.Razor v4無法加載文件或程序集'xxx'
無法加載文件或程序集'CfpPortal'或其依賴項之一。試圖加載格式不正確的程序。
堆棧軌道是如下
[BadImageFormatException:未能加載文件或程序集「CfpPortal」或它的一個依賴。嘗試加載程序的格式不正確。] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark & stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks )0 System.Reflection.RuntimeAssembly.nLoad(的AssemblyName文件名,字符串的代碼庫,證據assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark & stackMark,IntPtr的pPrivHostBinder,布爾throwOnFileNotFound,布爾forIntrospection,布爾suppressSecurityChecks)34 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName (AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark & stackMark,IntPtr pPrivHo stBinder,布爾throwOnFileNotFound,布爾forIntrospection,布爾suppressSecurityChecks)152 System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,證據assemblySecurity,StackCrawlMark & stackMark,IntPtr的pPrivHostBinder,布爾forIntrospection)77 System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,證據assemblySecurity,StackCrawlMark & stackMark,布爾forIntrospection)16 System.Reflection.Assembly.Load(字符串assemblyString)28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串的AssemblyName,布爾starDirective)38
[ConfigurationErrorsException:無法加載文件或程序集'CfpPortal'或它的一個依賴。嘗試加載格式不正確的程序。] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+218 系統。 Web.Configuration.CompilationSection.LoadAssembly(集信息AI)130個 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)170個 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()91 System.Web.Compilation。 BuildManager.CallPreStartInitMethods(String preStartInitListPath,Boolean & isRefAssemblyLoaded)+285 System.Web.Compilation.BuildManager.ExecutePreAppStart()+153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager AppManager的,IApplicationHost APPHOST,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,異常appDomainCreationException)516
[HttpException(0X80004005):無法加載文件或程序集CfpPortal'或其依賴之一。一個試圖加載程序使用不正確的格式。] System.Web.HttpRuntime.FirstRequestInit(HttpContext的上下文)9913572 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext的上下文中)101 System.Web.HttpRuntime。ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext的背景下)+254
我的web.config文件如下
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5" />
</system.Web>
-->
<system.web>
<compilation targetFramework="4.5" debug="true">
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.90.0" newVersion="1.0.90.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="CfpPortal" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
解決了這個問題,這是因爲在解決方案級別,我已經爲任何CPU設置了所有內容,但是在項目級別上,我有一個爲x64構建的項目。 – falfaddaghi