'Not running in a hosted service or the Development Fabric' 即使部署到 Azure



我有一个WebRole在Azure上部署的云服务下运行,但在今天发布后,我收到了以下错误:

The server encountered an error processing the request. 
The exception message is 'Not running in a hosted service or the Development Fabric.'. 
See server logs for more details. The exception stack trace is: 
at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.GetDefaultStartupInfoForCurrentRoleInstance() at 
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener..ctor() at 
Profile.LoginAuthenticate(Stream Params) in 
Profile.svc.vb:line 138 at 
SyncInvokeLoginAuthenticate(Object , Object[] , Object[] ) at 
System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at 
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at 
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at 
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)     at 
System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Profile.svc.vb的第138行很简单:

Dim trace As New Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener()

当人们在模拟器中本地运行时,这种错误似乎经常发生,但它已部署到Azure,所以我不明白它为什么不能在托管服务中运行。

在Visual Studio中打开角色属性,并检查是否勾选了"启用诊断"。此外(只是为了真正确保),请检查您的web.config:中是否已将Microsoft.WindowsAzure.Diagnostics添加为dependentAssembly

<dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.Diagnostics" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.8.0.0" newVersion="1.8.0.0" />
</dependentAssembly>

最新更新