2012-02-02 25 views
8

Tôi đang cố gắng làm theo ví dụ Hello về ServiceStack. Tôi đang sử dụng Visual Studio 2010, Win 7 64-bit nhưng IIS được cấu hình để chạy các ứng dụng 32-bit. Dự án Hello mà tôi tạo ra đang sử dụng ASP.Net MVC3. Tôi gặp phải lỗi này khi cố gắng truy cập siêu dữ liệu:Lỗi ServiceStack Đang tải WebHost Endpoint

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

Bạn đã cài đặt ServiceStack qua NuGet bằng cách nào? Thử cập nhật cả ServiceStack và WebActivator – mythz

+0

Có, thông qua Nuget. – cksanjose

+0

Chỉ cần thử phiên bản mới nhất trên NuGet, phù hợp với tôi. Nó có hoạt động khi bạn đang sử dụng WebDevServer nội bộ không? (tức là trong Thuộc tính dự án/Web/Sử dụng VS Dev WebServer) – mythz

Trả lời

9

Tôi gặp sự cố tương tự - khi tôi tạo dự án ASP.NET trống tôi gọi là - đủ khéo - ServiceStack. (Vấn đề kích hoạt) Khi tôi cập nhật tên dự án ASP (và tất cả các không gian tên tương ứng) thành một cái gì đó giống như ServiceStackExperiment - mọi thứ đều là kỳ lân và cầu vồng.

16

Đây là một bài rất cũ, nhưng điều này có thể giúp ai đó nếu họ nhận được một lỗi tương tự khi phát triển so với phiên bản ServiceStack 4.

Đã có một số tinh chỉnh cần thiết để các tập tin Web.Config nếu bạn quyết định để sao chép và dán từ một số hướng dẫn servicestack được viết cho phiên bản ServiceStack 3.

Http phần xử lý trong đó có không gian tên ServiceStack.Webhost sẽ cần phải được thay đổi để giống như sau

<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> 

Hy vọng nó sẽ giúp một ai đó!

+0

Cảm ơn, điều đó đã giúp! – derFunk