“未在托管服务或开发结构中运行”即使已部署到Azure

时间:2013-11-21 11:00:21

标签: vb.net azure azure-web-roles

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

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时,这个错误似乎经常发生,所以我不明白它是如何在托管服务中运行的。

1 个答案:

答案 0 :(得分:0)

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