Vb.net ';未在托管服务或开发结构中运行';即使部署到Azure

Vb.net ';未在托管服务或开发结构中运行';即使部署到Azure,vb.net,azure,azure-web-roles,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

我在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()

当人们在emulator中本地运行时,此错误似乎经常发生,但此错误已部署到Azure,因此我不明白它如何无法在托管服务中运行。

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

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


不确定这是否与您的错误有关,但您可能想查看以下帖子:他们在哪里讨论了与DotNetOpenAuth相同的错误。您在哪里看到此错误出现?它实际上无法启动跟踪监视器这一事实让我好奇,您在哪里看到这个错误,这可能暗示发生了什么。当前如何捕获此错误消息?