首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >System.Runtime.CallbackException in DurableInstancing

System.Runtime.CallbackException in DurableInstancing
EN

Stack Overflow用户
提问于 2011-10-10 12:48:46
回答 2查看 3.8K关注 0票数 1

最近,我开始在我的工作流应用程序中获得这个异常。

System.Runtime.CallbackException,System.Runtime.DurableInstancing,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35

用户回调抛出了一个异常。检查异常堆栈和内部异常,以确定失败的回调。

我通过运行以下类的Windows服务承载我的服务:

代码语言:javascript
运行
复制
public class WorkflowHost
{
    private readonly List<string> _services = new List<string>();

    private readonly Dictionary<string, WorkflowServiceHost> _hosts = new Dictionary<string, WorkflowServiceHost>();

    public WorkflowHost(IList<string> serviceNames)
    {
        foreach (string serviceName in serviceNames)
        {
            _services.Add(serviceName);
        } 
    }

    public void Start() 
    { 
        if (_hosts.Count > 0) 
        { 
            Stop(); 
        } 

        foreach(string serviceName in _services) 
        {
            WorkflowService service = LoadService(serviceName);                
            WorkflowServiceHost host = new WorkflowServiceHost(service);

            host.Faulted += new EventHandler(host_Faulted);

            try
            {
                host.Open();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            _hosts.Add(serviceName, host); 
        } 
    }

    void host_Faulted(object sender, EventArgs e)
    {
        Debug.WriteLine("Service Faulted");

        Start();
    }

    public void Stop() 
    { 
        if (_hosts.Count > 0) 
        { 
            foreach (string serviceName in _services) 
            {                    
                IDisposable host = _hosts[serviceName]; 
                host.Dispose(); 
            } 

            _hosts.Clear(); 
        } 
    } 

    private WorkflowService LoadService(String xamlxName)
    {
        string fullFilePath = Path.Combine(@"..\..\..\Services\Sales Funnel Workflow", xamlxName);

        WorkflowService service = XamlServices.Load(fullFilePath) as WorkflowService;

        if (service != null)
        {
            return service;
        }
        else
        {
            throw new NullReferenceException(string.Format("Unable to load service definition from {0}", fullFilePath));
        }
    }
}

下面是异常的完整堆栈跟踪:

代码语言:javascript
运行
复制
<StackTrace>
at System.ServiceModel.Channels.CommunicationObject.OnFaulted()
at System.ServiceModel.Channels.CommunicationObject.Fault()
at System.ServiceModel.Channels.CommunicationObject.Fault(Exception exception)
at  System.ServiceModel.Activities.Dispatcher.DurableInstanceManager.WaitAndHandleStoreEventsCallback(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.Runtime.AsyncResult.AsyncCompletionWrapperCallback(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.Runtime.DurableInstancing.InstanceHandle.WaitForEventsAsyncResult.Canceled()
at System.Runtime.DurableInstancing.InstanceHandle.Free()
at System.Activities.DurableInstancing.SqlWorkflowInstanceStoreLock.MarkInstanceOwnerLost(Int64 surrogateLockOwnerId)
at System.Activities.DurableInstancing.SqlWorkflowInstanceStoreLock.MarkInstanceOwnerLost(Int64 surrogateLockOwnerId, Boolean hasModificationLock)
at System.Activities.DurableInstancing.LockRenewalTask.HandleError(Exception exception)
at System.Activities.DurableInstancing.PersistenceTask.CommandCompletedCallback(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously, Exception exception)
at System.Activities.DurableInstancing.SqlWorkflowInstanceStoreAsyncResult.StartOperation()
at System.Activities.DurableInstancing.SqlWorkflowInstanceStoreAsyncResult.StartOperationCallback(Object state)
at System.Runtime.ActionItem.DefaultActionItem.Invoke()
at System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
<ExceptionString>System.Runtime.CallbackException: A user callback threw an exception.  Check the exception stack and inner exception to determine the callback that failed. ---&gt; System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Activities.WorkflowServiceHost, cannot be used for communication because it is in the Faulted state.
   at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.System.IDisposable.Dispose()
   at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.Stop() in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 67
   at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.Start() in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 30
   at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.host_Faulted(Object sender, EventArgs e) in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 57
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.ServiceModel.Channels.CommunicationObject.OnFaulted()
   --- End of inner exception stack trace ---</ExceptionString>
<InnerException>
<ExceptionType>System.ServiceModel.CommunicationObjectFaultedException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The communication object, System.ServiceModel.Activities.WorkflowServiceHost, cannot be used for communication because it is in the Faulted state.</Message>
<StackTrace>
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.System.IDisposable.Dispose()
at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.Stop() in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 67
at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.Start() in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 30
at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.host_Faulted(Object sender, EventArgs e) in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 57
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.ServiceModel.Channels.CommunicationObject.OnFaulted()
</StackTrace>
<ExceptionString>System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Activities.WorkflowServiceHost, cannot be used for communication because it is in the Faulted state.
   at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.System.IDisposable.Dispose()
   at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.Stop() in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 67
   at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.Start() in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 30
   at Zeller.SalesFunnel.WorkFlow.Service.WorkflowHost.host_Faulted(Object sender, EventArgs e) in C:\Projects\TFS\Zeller Corp Toolkit\Main\Toolkit\Services\ZSalesFunnelService\Zeller.SalesFunnel.WorkFlow.Service\WorkflowHost.cs:line 57
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.ServiceModel.Channels.CommunicationObject.OnFaulted()</ExceptionString>
</InnerException>
</Exception>

有人知道为什么我会得到这个吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-10-11 16:14:06

当主机发生故障时,尝试从回调到错误处理程序再次启动它。您必须让故障处理完成,并以其他方式重新启动主机。

票数 1
EN

Stack Overflow用户

发布于 2011-10-10 13:49:17

内部例外说:

System.ServiceModel.Activities.WorkflowServiceHost,是通信对象,由于它处于故障状态,因此不能用于通信。

这通常是前一次异常的结果。所以在这之前你需要看看发生了什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7712993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档