2012-02-02 25 views
8

我想跟隨ServiceStack的Hello示例。我使用Visual Studio 2010,Win 7 64位,但IIS配置爲運行32位應用程序。我創建的Hello項目使用ASP.Net MVC3。我得到這個錯誤試圖訪問元數據:ServiceStack錯誤加載WebHost端點

Could not load type 'ServiceStack.WebHost.Endpoints.AppHostBase' from assembly 'ServiceStack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.TypeLoadException: Could not load type 'ServiceStack.WebHost.Endpoints.AppHostBase' from assembly 'ServiceStack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[TypeLoadException: Could not load type 'ServiceStack.WebHost.Endpoints.AppHostBase' from assembly 'ServiceStack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.] 
    System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs) +0 
    System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs) +46 
    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +529 
    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103 
    System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit) +64 
    WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +145 
    WebActivator.ActivationManager.RunActivationMethods() +216 
    WebActivator.ActivationManager.RunPreStartMethods() +43 
    WebActivator.ActivationManager.Run() +69 

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load type 'ServiceStack.WebHost.Endpoints.AppHostBase' from assembly 'ServiceStack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'..] 
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677 

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load type 'ServiceStack.WebHost.Endpoints.AppHostBase' from assembly 'ServiceStack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'..] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9089964 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 
    System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258 
+0

你是如何通過NuGet安裝ServiceStack的?嘗試更新ServiceStack和WebActivator – mythz 2012-02-02 23:35:51

+0

是的,通過Nuget。 – cksanjose 2012-02-03 00:47:42

+0

剛剛嘗試過NuGet的最新版本,適合我。當您使用內部WebDevServer時它工作嗎? (即在項目屬性/ Web /使用VS開發Web服務器) – mythz 2012-02-03 00:58:31

回答

9

我遇到了同樣的問題 - 當我創建的空ASP.NET項目我把它叫做 - 足夠貼切 - ServiceStack。 (激活問題) 當我將ASP項目名稱(以及所有相應的命名空間)更新爲與ServiceStackExperiment類似的東西時 - 所有內容都是獨角獸和彩虹。

16

這是一個非常古老的職位,但如果對ServiceStack版本進行開發時,他們收到了類似的錯誤,這可能幫助別人4.

有,如果你決定需要複製到web.config文件中的一些調整和從被用於serviceStack版本寫了一些servicestack導遊粘貼3.

它具有ServiceStack.Webhost命名空間將需要HTTP處理程序部分被改成類似下面的

<httpHandlers> 
    <add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*"/> 
    </httpHandlers> 

    <handlers> 
    <add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />   
    </handlers> 

希望它能幫助別人!

+0

謝謝,這有幫助! – derFunk 2015-01-27 17:51:37