C# 使用Autofac解析对象时,即使使用ConfigurationWait(错误),异步上也会死锁
尽管我使用的是ConfigureAwait(false),但我在某些C代码上遇到了死锁。不幸的是,我不能一直使用async,所以我依赖ConfigureWait 情况是,我需要在web应用程序和控制台应用程序启动期间发出HTTP请求以从Azure AD检索数据库访问令牌。在这两种情况下,当Autofac试图解析触发web请求的数据库令牌时,程序都处于死锁状态。奇怪的是,它工作了两次,但第三次失败 自动传真模块:C# 使用Autofac解析对象时,即使使用ConfigurationWait(错误),异步上也会死锁,c#,dependency-injection,async-await,deadlock,C#,Dependency Injection,Async Await,Deadlock,尽管我使用的是ConfigureAwait(false),但我在某些C代码上遇到了死锁。不幸的是,我不能一直使用async,所以我依赖ConfigureWait 情况是,我需要在web应用程序和控制台应用程序启动期间发出HTTP请求以从Azure AD检索数据库访问令牌。在这两种情况下,当Autofac试图解析触发web请求的数据库令牌时,程序都处于死锁状态。奇怪的是,它工作了两次,但第三次失败 自动传真模块: public class AzureActiveDirectoryModule :
public class AzureActiveDirectoryModule : BaseModule
{
protected override bool SupportsMultipleModuleRegistrations => true;
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<AzureActiveDirectoryService>().As<IAzureActiveDirectoryService>();
builder.Register(c => c.Resolve<IAzureActiveDirectoryService>().GetAuthenticationContext())
.As<AuthenticationContext>()
.SingleInstance();
builder.Register(c => c.Resolve<IAzureActiveDirectoryService>().GetCertificateCredential())
.As<ClientAssertionCertificate>()
.SingleInstance();
builder.Register(c =>
c.Resolve<IAzureActiveDirectoryService>()
.GetDatabaseAccessToken(c.Resolve<AuthenticationContext>(), c.Resolve<ClientAssertionCertificate>()))
.Named<string>(PersistenceModule.DatabaseAccessToken);
}
}
公共类AzureActiveDirectoryModule:BaseModule
{
受保护的覆盖布尔支持MultipleModuleRegistrations=>true;
受保护的覆盖无效负载(ContainerBuilder builder)
{
builder.RegisterType().As();
builder.Register(c=>c.Resolve().GetAuthenticationContext())
.As()
.SingleInstance();
builder.Register(c=>c.Resolve().GetCertificateCredential())
.As()
.SingleInstance();
builder.Register(c=>
c、 解决()
.GetDatabaseAccessToken(c.Resolve(),c.Resolve())
.Named(PersistenceModule.DatabaseAccessToken);
}
}
发出HTTP请求的服务(我已将HTTP请求替换为对google的调用):
公共类AzureActiveDirectoryService:IAzureActiveDirectoryService
{
公共字符串GetDatabaseAccessToken(AuthenticationContext authContext、ClientAssertificate certCred)
{
尝试
{
返回AcquireDatabaseToken(certCred,authContext).Result;
}
捕获(例外情况除外)
{
错误(例如,“尝试检索数据库访问令牌时发生异常”);
}
返回字符串。空;
}
专用异步任务AcquireDatabaseToken(客户端证书Certificate certCred,AuthenticationContext authContext)
{
尝试
{
await DoHttpRequestAsync().ConfigureAwait(false);
返回字符串。空;
}
捕获(例外情况除外)
{
日志错误(例如,
“发生错误”,
例如ToString());
}
}
专用异步任务DoHttpRequestAsync()
{
使用(HttpClient=new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
HttpRequestMessage requestMessage=新建HttpRequestMessage();
requestMessage.RequestUri=新Uri(“http://www.google.com");
requestMessage.Headers.Accept.Clear();
client.Timeout=TimeSpan.From毫秒(30000);
尝试
{
wait client.sendaync(requestMessage).configurewait(false);
}
捕获(例外情况除外)
{
var a=例如消息;
}
}
返回字符串。空;
}
}
这是死锁线程(已编辑)的堆栈跟踪(在控制台应用程序中)——
mscorlib.dll!System.Threading.Monitor.Wait(对象obj,int毫秒计时,bool exitContext)未知
mscorlib.dll!System.Threading.Monitor.Wait(对象obj,int毫秒)未知
mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int毫秒计时,System.Threading.CancellationToken CancellationToken)未知
mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int毫秒计时,System.Threading.CancellationToken CancellationToken)未知
mscorlib.dll!System.Threading.Tasks.Task.InternalWait(int毫秒计时,System.Threading.CancellationToken CancellationToken)未知
mscorlib.dll!System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification)未知
mscorlib.dll!System.Threading.Tasks.Task.Result.get()未知Contoso.Infrastructure.dll!Infrastructure.Azure.AzureActiveDirectoryService.GetDatabaseAccessToken(Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext authContext,Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertificate certCred)第101行C#
Contoso.Infrastructure.dll!Infrastructure.Modules.Azure.AzureActiveDirectoryModule.Load.AnonymousMethod_uuuu2_2(Autofac.IComponentContext c)第30行c#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod_uuf(Autofac.IComponentContext c,System.Collections.Generic.IEnumerable p)未知
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod_uu0(Autofac.IComponentContext c,System.Collections.Generic.IEnumerable p)未知
Autofac.dll!Autofac.Core.Activators.DelegateActivator.ActivateInstance(Autofac.IComponentContext上下文,System.Collections.Generic.IEnumerable参数)未知
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable参数)未知
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute()未知
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope,Autofac.Core.IComponentRegistration注册,System.Collections.Generic.IEnumerable参数)未知
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration,System.Collections.Generic.IEnumerable参数)未知
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext上下文、Autofac.Core.Service服务、System.Collections.Generic.IEnumerable参数、out对象实例)未知
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext上下文、Autofac.Core.Service服务、System.Collections.Generic.IEnumerable参数)未知
Autofac.dll!Autofac.ResolutionExtensions.ResolveNamed(Autofac.IComponentContext,
public class AzureActiveDirectoryService : IAzureActiveDirectoryService
{
public string GetDatabaseAccessToken(AuthenticationContext authContext, ClientAssertionCertificate certCred)
{
try
{
return AcquireDatabaseToken(certCred, authContext).Result;
}
catch (Exception ex)
{
Log.Error(ex, "Exception occurred while attempting to retrieve database access token.");
}
return string.Empty;
}
private async Task<string> AcquireDatabaseToken(ClientAssertionCertificate certCred, AuthenticationContext authContext)
{
try
{
await DoHttpRequestAsync().ConfigureAwait(false);
return string.Empty;
}
catch (Exception ex)
{
Log.Error(ex,
"An error occurred",
ex.ToString());
}
}
private async Task<string> DoHttpRequestAsync()
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
HttpRequestMessage requestMessage = new HttpRequestMessage();
requestMessage.RequestUri = new Uri("http://www.google.com");
requestMessage.Headers.Accept.Clear();
client.Timeout = TimeSpan.FromMilliseconds(30000);
try
{
await client.SendAsync(requestMessage).ConfigureAwait(false);
}
catch (Exception ex)
{
var a = ex.Message;
}
}
return string.Empty;
}
}
mscorlib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout, bool exitContext) Unknown
mscorlib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout) Unknown
mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown
mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown
mscorlib.dll!System.Threading.Tasks.Task.InternalWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown
mscorlib.dll!System.Threading.Tasks.Task<string>.GetResultCore(bool waitCompletionNotification) Unknown
mscorlib.dll!System.Threading.Tasks.Task<System.__Canon>.Result.get() Unknown Contoso.Infrastructure.dll!Infrastructure.Azure.AzureActiveDirectoryService.GetDatabaseAccessToken(Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext authContext, Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate certCred) Line 101 C#
Contoso.Infrastructure.dll!Infrastructure.Modules.Azure.AzureActiveDirectoryModule.Load.AnonymousMethod__2_2(Autofac.IComponentContext c) Line 30 C#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod__f(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters, out object instance) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveNamed<string>(Autofac.IComponentContext context, string serviceName, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveNamed<string>(Autofac.IComponentContext context, string serviceName) Unknown
Contoso.Infrastructure.dll!Infrastructure.Modules.PersistenceModule.Load.AnonymousMethod__9_0(Autofac.IComponentContext c) Line 54 C#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod__f(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters, out object instance) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<System.Data.Common.DbConnection>(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<System.Data.Common.DbConnection>(Autofac.IComponentContext context) Unknown
Contoso.Infrastructure.dll!Infrastructure.Modules.PersistenceModule.Load.AnonymousMethod__9_1(Autofac.IComponentContext c) Line 62 C#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod__f(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid id, System.Func<object> creator) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters, out object instance) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Infrastructure.Persistence.IDbContext>(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Infrastructure.Persistence.IDbContext>(Autofac.IComponentContext context) Unknown
Contoso.Infrastructure.dll!Infrastructure.Modules.PersistenceModule.Load.AnonymousMethod__9_2(Autofac.IComponentContext c) Line 68 C#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod__f(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid id, System.Func<object> creator) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Activators.Reflection.AutowiringParameter.CanSupplyValue.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() Unknown
Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid id, System.Func<object> creator) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Features.Collections.CollectionRegistrationSource.RegistrationsFor.AnonymousMethod__1(Autofac.Core.IComponentRegistration cr) Unknown
System.Core.dll!System.Linq.Enumerable.WhereSelectArrayIterator<System.__Canon, System.__Canon>.MoveNext() Unknown
System.Core.dll!System.Linq.Buffer<object>.Buffer(System.Collections.Generic.IEnumerable<object> source) Unknown
System.Core.dll!System.Linq.Enumerable.ToArray<object>(System.Collections.Generic.IEnumerable<object> source) Unknown
Autofac.dll!Autofac.Features.Collections.CollectionRegistrationSource.RegistrationsFor.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters, out object instance) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<System.Collections.Generic.IEnumerable<Dispatching.Core.Tasks.Core.ITasksConfigurationSet>>(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<System.Collections.Generic.IEnumerable<Dispatching.Core.Tasks.Core.ITasksConfigurationSet>>(Autofac.IComponentContext context) Unknown
Contoso.Dispatching.Core.dll!Dispatching.Core.Modules.TaskRunnersModule.Load.AnonymousMethod__2_0(Autofac.IComponentContext c) Line 39 C#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod__f(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid id, System.Func<object> creator) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Activators.Reflection.AutowiringParameter.CanSupplyValue.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() Unknown
Autofac.dll!Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute.AnonymousMethod__0() Unknown
Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid id, System.Func<object> creator) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters, out object instance) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Dispatching.Core.Tasks.Core.ITaskManager>(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Dispatching.Core.Tasks.Core.ITaskManager>(Autofac.IComponentContext context) Unknown
Contoso.Dispatching.Core.dll!Dispatching.Core.Modules.DispatchingModule.Load.AnonymousMethod__2_2(Autofac.IComponentContext c) Line 73 C#
Autofac.dll!Autofac.RegistrationExtensions.Register.AnonymousMethod__f(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Builder.RegistrationBuilder.ForDelegate.AnonymousMethod__0(Autofac.IComponentContext c, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> p) Unknown
Autofac.dll!Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.InstanceLookup.Execute() Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Resolving.ResolveOperation.Execute(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.Core.Container.ResolveComponent(Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters, out object instance) Unknown
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Dispatching.Core.Worker.DispatcherWorker>(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Unknown
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Dispatching.Core.Worker.DispatcherWorker>(Autofac.IComponentContext context) Unknown
Topshelf.Autofac.dll!Topshelf.Autofac.ServiceConfiguratorExtensions.ConstructUsingAutofacContainer.AnonymousMethod__0_0(Topshelf.Runtime.HostSettings serviceFactory) Unknown
Topshelf.dll!Topshelf.Builders.DelegateServiceBuilder<Dispatching.Core.Worker.DispatcherWorker>.Build(Topshelf.Runtime.HostSettings settings) Unknown
Topshelf.dll!Topshelf.Builders.RunBuilder.Build(Topshelf.Builders.ServiceBuilder serviceBuilder) Unknown
Topshelf.dll!Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost() Unknown
Topshelf.dll!Topshelf.HostFactory.New(System.Action<Topshelf.HostConfigurators.HostConfigurator> configureCallback) Unknown
Contoso.Dispatcher.Shell.exe!Dispatcher.Shell.Program.Main() Line 48 C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) Unknown
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() Unknown
mscorlib.dll!System.Threading.LazyInitializer.EnsureInitializedCore<System.__Canon>(ref System.__Canon target, ref bool initialized, ref object syncLock, System.Func<System.__Canon> valueFactory) Unknown
mscorlib.dll!System.Threading.LazyInitializer.EnsureInitialized<Infrastructure.Persistence.Migrator.FluentMigratorSchemaVersion.MigrationsInfo>(ref Infrastructure.Persistence.Migrator.FluentMigratorSchemaVersion.MigrationsInfo target, ref bool initialized, ref object syncLock, System.Func<Infrastructure.Persistence.Migrator.FluentMigratorSchemaVersion.MigrationsInfo> valueFactory) Unknown
Contoso.Infrastructure.dll!Infrastructure.Persistence.Migrator.FluentMigratorSchemaVersion.EnsureInitialized() Line 43 C#
mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) Unknown
mscorlib.dll!System.Threading.WaitHandle.WaitOne(System.TimeSpan timeout, bool exitContext) Unknown
mscorlib.dll!System.Threading.WaitHandle.WaitOne(System.TimeSpan timeout) Unknown
Microsoft.ApplicationInsights.dll!Microsoft.ApplicationInsights.Channel.InMemoryTransmitter.Runner() Unknown
mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) Unknown
mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) Unknown
mscorlib.dll!System.Threading.WaitHandle.WaitOne() Unknown
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Common.AsyncResult.End<Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult<Microsoft.ServiceBus.Messaging.TopicDescription>>(System.IAsyncResult result) Unknown
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Common.AsyncResult<Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult<Microsoft.ServiceBus.Messaging.TopicDescription>>.End(System.IAsyncResult asyncResult) Unknown
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.EndGet<Microsoft.ServiceBus.Messaging.TopicDescription>(System.IAsyncResult asyncResult) Unknown
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.NamespaceManager.EndTopicExists(System.IAsyncResult result) Unknown
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.NamespaceManager.TopicExists(string path) Unknown
Contoso.Infrastructure.dll!Infrastructure.Azure.ServiceBus.ServiceBusTopic.Setup() Line 136 C#
public class AzureActiveDirectoryService : IAzureActiveDirectoryService
{
public string GetDatabaseAccessToken(AuthenticationContext authContext, ClientAssertionCertificate certCred)
{
try
{
return AcquireDatabaseToken(certCred, authContext);
}
catch (Exception ex)
{
Log.Error(ex, "Exception occurred while attempting to retrieve database access token.");
}
return string.Empty;
}
private string AcquireDatabaseToken(ClientAssertionCertificate certCred, AuthenticationContext authContext)
{
try
{
DoHttpRequest();
return string.Empty;
}
catch (Exception ex)
{
Log.Error(ex,
"An error occurred",
ex.ToString());
}
}
private string DoHttpRequest()
{
using (WebClient client = new WebClient())
{
return client.DownloadString("http://www.google.com");
}
return string.Empty;
}
}
return AcquireDatabaseToken(certCred,authContext).ConfigureAwait(false).GetAwaiter().GetResult();
return AcquireDatabaseToken(certCred,authContext).Result;