通过在内部使用Workflow的Web服务抛出ThrowKeyNotFoundException [英] A web service by using Workflow inside throw a ThrowKeyNotFoundException

查看:147
本文介绍了通过在内部使用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字典<  字符串,   对象 <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.

解决方案

Your exception must be thrown at this line

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



For some reason, it''s not finding your TRS object in the outputParameters dictionary

Can''t really advise more without knowing how HostWorkflowService.StartWorkflow populates the dictionary


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆