本文介绍了通过在内部使用Workflow的Web服务抛出ThrowKeyNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个服务器A和B,具有相同的部署程序包.
一个很好用.
B抛出错误:

 <  消息 > ; 字典中不存在给定的键.<  /Message  > 
            <   StackTrace  > . ThrowHelper.ThrowKeyNotFoundException()
在System.Collections.Generic.Dictionary`2.get_Item(TKey键)处
在webservice1.InvokeBusinessWorkflow [TWorkflow,TRQ,TRS](TRQ请求)
在webservice1.ProcessOneStepCal(ProcessOneStepCalSoapIn请求)
在SyncInvokeProcessOneStepCal(Object,Object [],Object [])
在System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke处(对象实例,对象[]输入,对象[]&输出)
在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)处
在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)处
在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)处
在System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)处<  /StackTrace  > 
            <  类型 >  System.Collections .Generic.KeyNotFoundException <  /Type  >  span> 



我完全不知道这是怎么发生的.(Web服务解决方案从2008年更新到2010年).
有人可以帮忙吗?

抱歉,我没有要求清楚上下文.
在我的解决方案中,我启动了这样的工作流程:

私有TRS InvokeBusinessWorkflow <   TWorkflow,    TRQ,    TRS  > (TRQ请求)
       {
           TRS响应;

           #region工作流程实施
           //建立工作流程的参数
           字典<  字符串,   对象 >  inputParameters = new字典<  字符串,   对象 > ();
           字典<  字符串,   对象 >  outputParameters = new字典<  字符串,   对象 > ();
           inputParameters.Add(typeof(TRQ).Name,request);

           //执行工作流程
           HostWorkflowService.StartWorkflow(typeof(TWorkflow),inputParameters,outputParameters);
           //根据参数构建响应.
           响应=(TRS)outputParameters [typeof(TRS).Name];
           #endregion

           返回响应;
       } 



IIS6在服务器A中可以很好地在主机上运行(我可以得到想要的东西).
但是在服务器B中抛出异常(已解部署的文件100%相同).
不幸的是,服务器B对我很重要,这使我感到疯狂.

response = (TRS)outputParameters[typeof(TRS).Name];



由于某种原因,它不在outputParameters字典中找到您的TRS对象

在不知道HostWorkflowService.StartWorkflow如何填充字典的情况下真的无法提供更多建议


I have two servers A and B,with the same deploy package.
A works well.
B throw an error:

<Message>The given key was not present in the dictionary.</Message>
            <StackTrace>at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at webservice1.InvokeBusinessWorkflow[TWorkflow,TRQ,TRS](TRQ request)
at webservice1.ProcessOneStepCal(ProcessOneStepCalSoapIn request)
at SyncInvokeProcessOneStepCal(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
            <Type>System.Collections.Generic.KeyNotFoundException</Type>



I toally have no idea how this could happen.(the web service solution used to be updated from 2008 to 2010).
Could anybody help?

Sorry,I didn''t claim the context clear.
In my solution,I start a workflow like this:

private TRS InvokeBusinessWorkflow<TWorkflow, TRQ, TRS>(TRQ request)
       {
           TRS response;

           #region Workflow implementation
           // Build the parameters for the Workflow
           Dictionary<string, object> inputParameters = new Dictionary<string, object>();
           Dictionary<string, object> outputParameters = new Dictionary<string, object>();
           inputParameters.Add(typeof(TRQ).Name, request);

           // Execute the Workflow
           HostWorkflowService.StartWorkflow(typeof(TWorkflow), inputParameters, outputParameters);
           // Build the response based on the parameters.
           response = (TRS)outputParameters[typeof(TRS).Name];
           #endregion

           return response;
       }



It works well host by IIS6 in server A(I can get what I want).
but throw exception in server B(the deloyed files are 100% the same).
unfortunately, the server B is important to me and this dirves me crasy.

解决方案


这篇关于通过在内部使用Workflow的Web服务抛出ThrowKeyNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 03:02