Azure 云服务中托管的 WCF 服务发布后出现错误

标签 wcf iis azure

我有一个包含多个 WCF 服务(REST 和 SOAP 混合)的项目。该项目已在本地运行 6 个月,没有出现任何问题。我们正在将其转移到 Azure,但遇到了一个阻止我们上线的问题。

该项目使用 Autofac 作为 IOC。我们准备将其托管在 Azure 的云服务中。在 Azure 模拟器本地运行时,一切似乎都能正常工作,但是一旦我们使用云服务项目进行部署,一切都会正确构建和部署,但在尝试访问服务时会收到以下错误。

Server Error in '/' Application.


Value cannot be null. Parameter name: key

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.ArgumentNullException: Value cannot be null. Parameter name: key 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:

[ArgumentNullException: Value cannot be null.

Parameter name: key]

   System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) +48

   System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +38

   System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +20

   System.ServiceModel.Dispatcher.WebHttpDispatchOperationSelector..ctor(ServiceEndpoint endpoint) +2459

   System.ServiceModel.Description.WebHttpBehavior.GetOperationSelector(ServiceEndpoint endpoint) +125

   System.ServiceModel.Description.WebHttpBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) +1955

   System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +4245

   System.ServiceModel.ServiceHostBase.InitializeRuntime() +119

   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +45

   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +553

   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +350

   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1614

[ServiceActivationException: The service '/Event/Calendar' cannot be activated due to an exception during compilation.  The exception message is: Value cannot be null.

Parameter name: key.]

   System.Runtime.AsyncResult.End(IAsyncResult result) +925

   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +528

   System.ServiceModel.Activation.AspNetRouteServiceHttpHandler.EndProcessRequest(IAsyncResult result) +107

   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +151

服务配置端点似乎存在问题。这是通过 Autofac WCF 集成使用 OOTB RouteTable 进行注册的:

RouteTable.Routes.Add(new ServiceRoute("Event/Calendar", new AutofacWebServiceHostFactory(), typeof(CalendarSvc)));

所有这些在 IIS 和本地 Azure 模拟器中都可以正常工作,但一旦部署到云服务,我们就会遇到问题。

最佳答案

观察到了确切的问题。通过取消此托管服务上的 IntelliTrace 即可解决。

我从 VS2013 进行发布,并在发布过程中标记了“启用 IntelliTrace”。一旦我取消了此选项并重新发布 - 一切正常......

关于Azure 云服务中托管的 WCF 服务发布后出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25268119/

相关文章:

iis - 剔除/管理 Blob 存储中的 Azure 日志文件/失败请求日志

Azure SQL 池弹性

Azure静态Web应用程序生成的envs和azure AD租户回复url

.net - 为什么找不到我的自定义 WCF 行为扩展元素类型?

c# - 客户端如何知道 wcf 服务正在运行?

IIS 请求偶尔会卡在 BeginRequest 中 - IIS Web Code

iis - 上传时无法打开网站上的其他页面?

Azure 逻辑应用 - Liquid 连接器 - Liquid 模板引擎的版本/风格?

c# - Windows 服务属性

c# - WP7 推送通知服务器设置