【问题标题】:ServiceStack Error Loading WebHost Endpoint加载 WebHost 端点的 ServiceStack 错误
【发布时间】:2012-02-25 14:11:46
【问题描述】:

我正在尝试遵循 ServiceStack 的 Hello 示例。我使用的是 Visual Studio 2010,Win 7 64 位,但 IIS 配置为运行 32 位应用程序。我创建的 Hello 项目使用的是 ASP.Net MVC3。我在尝试访问元数据时收到此错误:

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

【问题讨论】:

  • 您是如何通过 NuGet 安装 ServiceStack 的?尝试同时更新 ServiceStack 和 WebActivator
  • 刚刚在 NuGet 上试用了最新版本,对我有用。当您使用内部 WebDevServer 时它是否有效? (即在 Project Properties/Web/Use VS Dev WebServer 中)
  • 已经设置为使用 VS 开发服务器。我认为这是 web.config 文件。有一条消息指出找不到位置元素“ServiceStack”。谢谢你的帮助!!
  • 注意:如果您通过 NuGet 安装它,则 location 元素上的自定义路径应该是“api”而不是“servicestack”。您是否尝试过手动安装以及通过 NuGet 安装?我会删除所有内容并重新开始。

标签: visual-studio-2010 windows-7 64-bit servicestack


【解决方案1】:

这是一篇非常古老的帖子,但如果有人在针对 ServiceStack 版本 4 进行开发时收到类似的错误,这可能会对他们有所帮助。

如果您决定从为 ServiceStack 版本 3 编写的一些 servicestack 指南中复制和粘贴,则需要对 Web.Config 文件进行一些调整。

需要将具有 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>

希望对某人有所帮助!

【讨论】:

    【解决方案2】:

    我遇到了同样的问题 - 当我创建 Empty ASP.NET 项目时,我称之为 - 恰如其分 - ServiceStack。 (激活问题) 当我将我的 ASP 项目名称(以及所有相应的命名空间)更新为类似于 ServiceStackExperiment 的名称时 - 一切都是独角兽和彩虹。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-27
      • 1970-01-01
      • 1970-01-01
      • 2016-04-03
      • 2017-09-13
      • 2020-08-14
      相关资源
      最近更新 更多