在字典中找不到键
key was not found in dictionary
以下异常,似乎表明无法找到其中一个配置值:
{
"error": {
"code": "",
"message": "An error has occurred.",
"innererror": {
"message": "One or more errors occurred.",
"type": "System.AggregateException",
"stacktrace": " at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__24`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.V2.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsyncV2>d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<ContinueWith>d__12.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at Sales.o777.OrderManagement.Controller.OrderCapturesController.<Post>d__9.MoveNext() in C:\ws\CleanRoom\DEV\Source\ENTERPRISEAPI\abc.API.Sales.o777.OrderManagement\Sales.o777.OrderManagement\Controller\OrderCaptureController.cs:line 75\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"internalexception": {
"message": "The given key was not present in the dictionary.",
"type": "System.Collections.Generic.KeyNotFoundException",
"stacktrace": " at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\r\n at OCLineItemsActor.Interfaces.IOCLineItemsActor_.actor.disp.IOCLineItemsActorMethodDispatcher.OnDispatchAsync(Int32 , Object , IServiceRemotingRequestMessageBody , IServiceRemotingMessageBodyFactory , CancellationToken )\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.ActorMethodDispatch(ActorMethodDispatcherBase methodDispatcher, ActorBase actor, Int32 interfaceId, Int32 methodId, IServiceRemotingRequestMessageBody requestBody, IServiceRemotingMessageBodyFactory remotingMessageBodyFactory, CancellationToken innerCancellationToken)\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<>c__DisplayClass30_0.<InvokeAsync>b__0(ActorBase actor, CancellationToken innerCancellationToken)\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<DispatchToActorConcurrencyLockHeldAsync>d__48`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<DispatchToActorAsync>d__29`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<DispatchToActorAsync>d__29`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Runtime.ServiceRemotingCancellationHelper.<Dispatabcequest>d__5`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Actors.Remoting.V2.Runtime.ActorServiceRemotingDispatcher.<HandleActorMethodDispatchAsync>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime.FabricTransportMessageHandler.<RequestResponseAsync>d__7.MoveNext()"
}
}
}
}
流量:
- post一个微服务机构
- 该微服务启动了一个编排,其中一个正在使用共享接口上的方法
IOCLineItemsActor
根据下面,异常发生在第75行,如innerexception中所见:
...\Sales.o777.OrderManagement\Controller\OrderCaptureController.cs:line 75\r\n--- End of stack trace from pr...
第 74/75 行如下:
var proxy = ActorProxy.Create<IOCLineItemsActor>(ActorId.CreateRandom(), new Uri(@"fabric:/abc.API/OCLineItemsActor/OCLineItemsActorService"));
await proxy.MergeLineItemsToOpportunity(orderCapture.Id, (Guid)orderCapture.OpportunityId); //this is line 75 ! seems like it may be looking for a onfig setting here?
发布开发环境时,我们没有得到given key was not present in dictionary异常;但是,当我发布到 QA 时,我们确实得到了这个异常。
我比较了 ApplicationParameters 文件(dev 与 qa),它们是相同的。
我做错了什么?我如何找出它缺少哪个密钥?
这里是MergeLineItemsToOpportunity
internal class OCLineItemsActor : Actor, IOCLineItemsActor
{
/// <summary>
/// Initializes a new instance of OCLineItemsActor
/// </summary>
/// <param name="actorService">
/// The Microsoft.ServiceFabric.Actors.Runtime.ActorService that will host this ocLineItemsActor
/// instance.
/// </param>
/// <param name="actorId">The Microsoft.ServiceFabric.Actors.ActorId for this ocLineItemsActor instance.</param>
public OCLineItemsActor(ActorService actorService, ActorId actorId)
: base(actorService, actorId)
{
CMConnectionString = FabricRuntime.GetActivationContext().GetConfigurationPackageObject("Config")
.Settings.Sections["CRMWebService"].Parameters["CMDatabaseConnection"].Value;
CRMConnectionString = FabricRuntime.GetActivationContext().GetConfigurationPackageObject("Config")
.Settings.Sections["CRMWebService"].Parameters["CRMDatabaseConnection"].Value;
SprocExecutor = new SprocExecutor(CMConnectionString, CRMConnectionString);
}
public Task MergeLineItemsToOpportunity(int orderCaptureId, Guid opportunityId)
{
OCLineItemsEventSource.Current.Message("orderCaptureId: " + orderCaptureId);
var executor = new SprocExecutor(CMConnectionString, CRMConnectionString);
SprocExecutor.MergeLineItemsToOpportunity(orderCaptureId, opportunityId);
return Task.CompletedTask;
}
}
我没有直接引用 Interfaces
DLL,而是引用了包含接口的 csproj
文件。我不知道为什么会这样。
以下异常,似乎表明无法找到其中一个配置值:
{
"error": {
"code": "",
"message": "An error has occurred.",
"innererror": {
"message": "One or more errors occurred.",
"type": "System.AggregateException",
"stacktrace": " at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__24`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.V2.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsyncV2>d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<ContinueWith>d__12.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at Sales.o777.OrderManagement.Controller.OrderCapturesController.<Post>d__9.MoveNext() in C:\ws\CleanRoom\DEV\Source\ENTERPRISEAPI\abc.API.Sales.o777.OrderManagement\Sales.o777.OrderManagement\Controller\OrderCaptureController.cs:line 75\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"internalexception": {
"message": "The given key was not present in the dictionary.",
"type": "System.Collections.Generic.KeyNotFoundException",
"stacktrace": " at System.Collections.Generic.Dictionary`2.get_Item(TKey key)\r\n at OCLineItemsActor.Interfaces.IOCLineItemsActor_.actor.disp.IOCLineItemsActorMethodDispatcher.OnDispatchAsync(Int32 , Object , IServiceRemotingRequestMessageBody , IServiceRemotingMessageBodyFactory , CancellationToken )\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.ActorMethodDispatch(ActorMethodDispatcherBase methodDispatcher, ActorBase actor, Int32 interfaceId, Int32 methodId, IServiceRemotingRequestMessageBody requestBody, IServiceRemotingMessageBodyFactory remotingMessageBodyFactory, CancellationToken innerCancellationToken)\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<>c__DisplayClass30_0.<InvokeAsync>b__0(ActorBase actor, CancellationToken innerCancellationToken)\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<DispatchToActorConcurrencyLockHeldAsync>d__48`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<DispatchToActorAsync>d__29`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.ServiceFabric.Actors.Runtime.ActorManager.<DispatchToActorAsync>d__29`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Runtime.ServiceRemotingCancellationHelper.<Dispatabcequest>d__5`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Actors.Remoting.V2.Runtime.ActorServiceRemotingDispatcher.<HandleActorMethodDispatchAsync>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime.FabricTransportMessageHandler.<RequestResponseAsync>d__7.MoveNext()"
}
}
}
}
流量:
- post一个微服务机构
- 该微服务启动了一个编排,其中一个正在使用共享接口上的方法
IOCLineItemsActor
根据下面,异常发生在第75行,如innerexception中所见:
...\Sales.o777.OrderManagement\Controller\OrderCaptureController.cs:line 75\r\n--- End of stack trace from pr...
第 74/75 行如下:
var proxy = ActorProxy.Create<IOCLineItemsActor>(ActorId.CreateRandom(), new Uri(@"fabric:/abc.API/OCLineItemsActor/OCLineItemsActorService"));
await proxy.MergeLineItemsToOpportunity(orderCapture.Id, (Guid)orderCapture.OpportunityId); //this is line 75 ! seems like it may be looking for a onfig setting here?
发布开发环境时,我们没有得到given key was not present in dictionary异常;但是,当我发布到 QA 时,我们确实得到了这个异常。
我比较了 ApplicationParameters 文件(dev 与 qa),它们是相同的。
我做错了什么?我如何找出它缺少哪个密钥?
这里是MergeLineItemsToOpportunity
internal class OCLineItemsActor : Actor, IOCLineItemsActor
{
/// <summary>
/// Initializes a new instance of OCLineItemsActor
/// </summary>
/// <param name="actorService">
/// The Microsoft.ServiceFabric.Actors.Runtime.ActorService that will host this ocLineItemsActor
/// instance.
/// </param>
/// <param name="actorId">The Microsoft.ServiceFabric.Actors.ActorId for this ocLineItemsActor instance.</param>
public OCLineItemsActor(ActorService actorService, ActorId actorId)
: base(actorService, actorId)
{
CMConnectionString = FabricRuntime.GetActivationContext().GetConfigurationPackageObject("Config")
.Settings.Sections["CRMWebService"].Parameters["CMDatabaseConnection"].Value;
CRMConnectionString = FabricRuntime.GetActivationContext().GetConfigurationPackageObject("Config")
.Settings.Sections["CRMWebService"].Parameters["CRMDatabaseConnection"].Value;
SprocExecutor = new SprocExecutor(CMConnectionString, CRMConnectionString);
}
public Task MergeLineItemsToOpportunity(int orderCaptureId, Guid opportunityId)
{
OCLineItemsEventSource.Current.Message("orderCaptureId: " + orderCaptureId);
var executor = new SprocExecutor(CMConnectionString, CRMConnectionString);
SprocExecutor.MergeLineItemsToOpportunity(orderCaptureId, opportunityId);
return Task.CompletedTask;
}
}
我没有直接引用 Interfaces
DLL,而是引用了包含接口的 csproj
文件。我不知道为什么会这样。