2012-07-05 25 views
22

Chúng tôi có dịch vụ WCF (không có bảo mật) đang được truy cập bởi trang web MVC3. Trên các máy phát triển, chúng tôi không có vấn đề gì với nó nhưng khi thiết lập TeamCity của chúng tôi xây dựng phiên bản trung tâm và triển khai nó dưới IIS7 lần đầu tiên chúng tôi tải trang MVC3 và nó truy cập dịch vụ WCF - cuộc gọi dịch vụ trả về thông báo:Dịch vụ WCF trả về "dịch vụ yêu cầu '...' không thể kích hoạt" lần đầu tiên truy cập từ trang MVC

System.ServiceModel.ServiceActivationException: Không thể kích hoạt dịch vụ được yêu cầu, 'http: // localhost: 83/ABCStaticData/StaticDataService.svc'. Xem nhật ký theo dõi chẩn đoán của máy chủ để biết thêm thông tin. **

Nếu chúng tôi lập tức truy cập cùng một trang web, mọi thứ hoạt động tốt.

server chồng theo dõi khi nó ném lỗi này là:

server stack trace:

at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory1 factory, WebException responseException, ChannelBinding channelBinding) 
at System.ServiceModel.Channels.HttpChannelFactory1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout 
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
at ABC.StaticData.Editor.StaticDataServiceProxy.IStaticDataService.GetAllMarkets() 
at ABC.StaticData.Editor.StaticDataServiceProxy.StaticDataServiceClient.GetAllMarkets() in c:\BuildAgent\work\55a3bcc468adcccb\StaticData\ABC.StaticData.Editor\Service References\StaticDataServiceProxy\Reference.cs:line 3195 
at ABC.StaticData.Editor.Controllers.MarketsController.<>c__DisplayClass22.<.ctor>b__13() in c:\BuildAgent\work\55a3bcc468adcccb\StaticData\ABC.StaticData.Editor\Controllers\MarketsController.cs:line 263 
at ABC.StaticData.Editor.Controllers.MarketsController.Index() in c:\BuildAgent\work\55a3bcc468adcccb\StaticData\ABC.StaticData.Editor\Controllers\MarketsController.cs:line 306 

Có ai có bất kỳ ý tưởng về những gì có thể gây ra vấn đề hoặc để bắt đầu tìm kiếm ở đâu?

CẬP NHẬT: Tôi quên đề cập đến đầu tiên rằng nếu chúng tôi không truy cập trang web trong một thời gian và sau đó quay trở lại, nó sẽ đưa ra cùng một lỗi - sau đó hoạt động lại lần thứ hai.

UPDATE2: Đây là sự kiện ghi nhật ký văn bản:

WebHost failed to process a request. 
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/3043589 
Exception: System.ServiceModel.ServiceActivationException: The service '/ABCStaticData/StaticDataService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load type 'System.Runtime.CompilerServices.AsyncStateMachineAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.. ---> System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.AsyncStateMachineAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 
    at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) 
    at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) 
    at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) 
    at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) 
    at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable) 
    at System.Reflection.CustomAttribute.IsDefined(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit) 
    at System.Reflection.RuntimeMethodInfo.IsDefined(Type attributeType, Boolean inherit) 
    at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute(MemberInfo member, Type type) 
    at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject(MemberInfo member) 
    at Ninject.Selection.Selector.<>c__DisplayClassa.<SelectMethodsForInjection>b__9(IInjectionHeuristic h) 
    at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) 
    at Ninject.Selection.Selector.<SelectMethodsForInjection>b__8(MethodInfo m) 
    at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext() 
    at Ninject.Planning.Strategies.MethodReflectionStrategy.Execute(IPlan plan) 
    at Ninject.Planning.Planner.<>c__DisplayClass1.<CreateNewPlan>b__0(IPlanningStrategy s) 
    at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T](IEnumerable`1 series, Action`1 action) 
    at Ninject.Planning.Planner.CreateNewPlan(Type type) 
    at Ninject.Planning.Planner.GetPlan(Type type) 
    at Ninject.Activation.Providers.StandardProvider.Create(IContext context) 
    at Ninject.Activation.Context.Resolve() 
    at Ninject.KernelBase.<>c__DisplayClass10.<Resolve>b__c(IBinding binding) 
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 
    at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) 
    at Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) 
    at Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) 
    at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) 
    at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass4.<Create>b__2(ITarget target) 
    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() 
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source) 
    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) 
    at Ninject.Activation.Providers.StandardProvider.Create(IContext context) 
    at Ninject.Activation.Context.Resolve() 
    at Ninject.KernelBase.<>c__DisplayClass10.<Resolve>b__c(IBinding binding) 
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 
    at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) 
    at Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) 
    at Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) 
    at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) 
    at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass4.<Create>b__2(ITarget target) 
    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() 
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source) 
    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) 
    at Ninject.Activation.Providers.StandardProvider.Create(IContext context) 
    at Ninject.Activation.Context.Resolve() 
    at Ninject.KernelBase.<>c__DisplayClass10.<Resolve>b__c(IBinding binding) 
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source) 
    at Ninject.Extensions.Wcf.BaseNinjectServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) 
    at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) 
    --- End of inner exception stack trace --- 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) 
    at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity) 
Process Name: w3wp 
Process ID: 3248 

Chỉ cần một điểm mà chúng ta đang phát triển sử dụng .NET 4.5 và Visual Studio 2012 RC.

+0

Ngoại lệ bên trong là gì? – abatishchev

+0

Không có ngoại lệ bên trong. – trembler2003

+0

Bạn có chắc chắn không? Văn bản mục nhập sự kiện thích hợp là gì? – abatishchev

Trả lời

0

Phần mở rộng .svc có được đăng ký trong IIS không?

Xem MSDN để biết thêm chi tiết.

+0

Đoán vì nó tải lần thứ hai. Đã nhanh chóng đăng câu trả lời của tôi. Lấy làm tiếc! – Jocke

2

Tôi đã nhấn cùng loại "Không thể tải loại 'System.Runtime.CompilerServices.AsyncStateMachineAttribute'", mà tôi phát hiện ra là vì tôi đã xây dựng ứng dụng của mình bằng cách sử dụng VS 2012 RTM, nhưng sau đó đã cố gắng triển khai nó trên máy chỉ có 4.5 Beta. AsyncStateMachineAttribute là một kiểu mới được thêm vào sau bản Beta.

23

Tôi vừa quản lý để giải quyết vấn đề tương tự ngẫu nhiên 'System.ServiceModel.ServiceActivationException' (ném ngoại lệ, sau đó chạy vào lần truy cập thứ hai.). Lý do cho trường hợp ngoại lệ trong trường hợp của tôi là thiếu bộ nhớ trên máy chủ. Để xác nhận vấn đề bộ nhớ, bạn có thể làm như sau:

Ứng dụng gọi dịch vụ web:

System.ServiceModel.ServiceActivationException: The requested service, 'XXX' could not be activated. See the server's diagnostic trace logs for more information. 

Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding) 
    at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

WCF trace log: không có gì lưu lại.

Trên máy chủ lưu trữ dịch vụ WCF (giống như các ứng dụng gọi điện thoại btw) trong nhật ký sự kiện ngoại trừ nhiều thông tin tào lao tôi đã tìm thấy:

chi tiết sự kiện tùy chỉnh:

WebHost failed to process a request. 
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/58366981 
Exception: System.ServiceModel.ServiceActivationException: The service 'xxx' cannot be activated due to an exception during compilation. The exception message is: Memory gates checking failed because the free memory (xxx bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.. ---> System.InsufficientMemoryException: Memory gates checking failed because the free memory (xxx bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element. 

Vì vậy, giải pháp đối với tôi là: 1. thêm ram khác 2.phát hành một số ram (giải pháp tạm thời) 3. cập nhật web cấu hình của dịch vụ web:

<configuration> 
    <system.serviceModel> 
    <serviceHostingEnvironment ... minFreeMemoryPercentageToActivateService="0" /> 
    </system.serviceModel> 
</configuration> 
+0

tuyệt vời, RAM cũng là vấn đề của tôi !! –

+1

# 1 là không khả thi đối với tôi (trở ngại quan liêu). Cố gắng # 3, làm việc như một say mê, ít nhất là cho bây giờ. Cảm ơn rất nhiều! :) – Quester

0

Tôi đã có vấn đề quá, những gì tôi đã làm là:

  • Vào thư mục trong file hệ thống nơi mà các dịch vụ cư trú
  • bạn sẽ có 2 tác phẩm cho các dịch vụ
    • yourService.svc
    • yourService.svc.cs
  • Mở tệp yourService.svc và chắc chắn rằng dịch vụ của bạn được cấu hình, và mã đằng sau trông như thế này:

    <%@ ServiceHost Language="C#" Debug="true" Service="YourNamespace.yourService.svc" CodeBehind="yourService.svc.cs" %> 
    

Tôi cố định vấn đề của tôi như vậy. Tôi hy vọng nó sẽ giúp!

11

Tôi có vấn đề này quá và chỉ đơn giản là đưa

<serviceHostingEnvironment minFreeMemoryPercentageToActivateService="1"> 

dưới

<system.serviceModel>

Và tất cả mọi thứ hoạt động tốt.

+0

minFreeMemoryPercentageToActivateService = "1" – Jagd

+0

Thẻ 'serviceHostingEnvironment' của bạn không được đóng, nó sẽ kết thúc bằng '/>' chứ không phải '>'. – SharpC

-1

Mỗi lần tôi gặp vấn đề tương tự, tôi khởi động lại máy tính và hoạt động tốt. Nó giải phóng bộ nhớ

+1

Chúng tôi không thể khởi động lại PC mỗi khi lỗi này xảy ra. Phải không? – Irshad

+0

Tôi đồng ý với bạn, chúng tôi không thể đủ khả năng để khởi động lại nó mỗi ngày hoặc lâu hơn. Đã cạn kiệt tất cả các đề xuất ở trên và vẫn không hoạt động. Chúng tôi quên thực tế đơn giản là máy cần khởi động lại sau khi chạy trong nhiều tuần để giải phóng tài nguyên. Và Microsoft khuyến nghị rằng: "Khởi động lại thường xuyên Khởi động lại PC của bạn ít nhất một lần một tuần, đặc biệt nếu bạn sử dụng nó rất nhiều. Đó là cách tốt để xóa bộ nhớ và đảm bảo rằng mọi quá trình và dịch vụ bắt đầu chạy bị đóng xuống." http://windows.microsoft.com/en-US/windows7/optimize-Windows-7-for-better-performance?72a92270 – LapelCard

0

Kiểm tra bộ nhớ của máy chủ bạn đang lưu trữ các dịch vụ chưa đầy.

Các vấn đề liên quan