我正在尝试遵循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
答案 0 :(得分:16)
这是一篇非常古老的帖子,但如果他们在针对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>
希望它有所帮助!
答案 1 :(得分:9)
我遇到了同样的问题 - 当我创建空ASP.NET项目时,我称之为 - 恰如其分 - ServiceStack。 (激活问题) 当我将我的ASP项目名称(以及所有相应的命名空间)更新为类似于ServiceStackExperiment的东西时 - 一切都是独角兽和彩虹。