Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8651399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:03:39+00:00 2026-06-12T14:03:39+00:00

I have veeeery simple workflow hosted as a service. I just want is to

  • 0

I have veeeery simple workflow hosted as a service. I just want is to handle exceptions from this workflow.

My workflow gets ‘string’ as a parameter and tries to cast it to int. So whenever I send data like ‘asasafs’ it fails and throws exception. Very simple 🙂

I’ve read that I can create my own WorkflowServiceHostFactory, but unfortunatelly I can’t accomplish my simple task, this is my implementation:

public class MyServiceHostFactory : System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory
{
    protected override WorkflowServiceHost CreateWorkflowServiceHost(Activity activity, Uri[] baseAddresses)
    {
        return base.CreateWorkflowServiceHost(activity, baseAddresses);
    }

    protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri[] baseAddresses)
    {

        var host = base.CreateWorkflowServiceHost(service, baseAddresses);

        WorkflowRuntimeBehavior wrb = host.Description.Behaviors.Find<WorkflowRuntimeBehavior>();
        if (wrb == null)
            wrb = new WorkflowRuntimeBehavior();
        wrb.WorkflowRuntime.ServicesExceptionNotHandled += WorkflowRuntime_ServicesExceptionNotHandled;
        wrb.WorkflowRuntime.Started += WorkflowRuntime_Started;
        wrb.WorkflowRuntime.WorkflowCompleted += WorkflowRuntime_WorkflowCompleted;
        host.Description.Behaviors.RemoveAll<WorkflowRuntimeBehavior>();
        host.Description.Behaviors.Add(wrb);
        host.Faulted += host_Faulted;
        host.UnknownMessageReceived += host_UnknownMessageReceived;
        return host;
    }

    void workflowRuntime_WorkflowCreated(object sender, WorkflowEventArgs e)
    {
        throw new NotImplementedException();
    }

    void WorkflowRuntime_WorkflowCompleted(object sender, System.Workflow.Runtime.WorkflowCompletedEventArgs e)
    {
        throw new NotImplementedException();
    }

    void WorkflowRuntime_Started(object sender, System.Workflow.Runtime.WorkflowRuntimeEventArgs e)
    {
        throw new NotImplementedException();
    }

    void WorkflowRuntime_ServicesExceptionNotHandled(object sender, System.Workflow.Runtime.ServicesExceptionNotHandledEventArgs e)
    {
        throw new NotImplementedException();
    }

    void host_UnknownMessageReceived(object sender, System.ServiceModel.UnknownMessageReceivedEventArgs e)
    {
        throw new NotImplementedException();
    }

    void host_Faulted(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }
} 

I’m using Visual Studio 2k10 and iisexpress, and whenever workflow throws an exception, debugger do not break in any of my event handlers.
Do you know how to do it properly ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:03:42+00:00Added an answer on June 12, 2026 at 2:03 pm

    It really depends on what you are are trying to do. For one sending a SOAP message to a workflow uses the standard WCF stack so with an IErrorHandler or a message inspector you should be able to see errors being returned to the client.

    However that is only part of the story. A workflow is not done when the response is send back to the client. Instead it continues executing for as long as it has any work to do. And as that is after the response to the client is send the WCF stack is not going to show you any errors that occurred.

    Instead using a TrackingParticipant and checking for a FaultPropagationRecord will tell you about any exception that is not handled in an activity itself. It might still be handled by a TryCatch activity. Checking for a WorkflowInstanceUnhandledExceptionRecord tells you that the exception was not handled in the workflow and propagated all the way to the runtime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a look at this snippet: #include <string> #include <iostream> #include <vector> using namespace
Have been scatching my head about this - and I reckon it's simple but
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
Have a painfully simple blog Post creator, and I'm trying to check if the
have a nice day. I got problem when trying to create an image from
Have been trying to figure this problem out for a while now and was
have Intel Core i7 laptop with 8 GB ram. This is my first time
Have written all the code in a silverlight class library (dll) and linked this
Have a simple iPhone app with a single UIViewController and two Views in one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.