title: WCF RIA Exception on Invoke operation interrupts Caliburn.Micro coroutine execution?
body: <p>I am executing a series of Caliburn.Micro IResults by yield returning them from an IEnumerable method called by a Caliburn.Micro action message. The first IResult calls a WCF RIA service Invoke operation. Sometimes this operation fails and throws an exception. This is handled in the IResult where the InvokeOperation object is checked for error, I mark the error as handled and set the IResult's error message field to the error so I can recover it from the client.</p>
  
  <p>The problem is that for some reason this interrupts the co-routine executing. I can't think of any good reason why, but when I'm in debug mode VS skips to the <strong>server</strong> code and bring up the unhandled exception helper telling me there was an uncaught exception (duh), and the co-routine never continues executing the other members of the IEnumerable.</p>
  
  <p>Here is some of the code.</p>
  
  <p>Called from the Action Message:</p>
  
  <pre><code>    public IEnumerable&lt;IResult&gt; Submit()
      {
          var register = new RegisterUserResult(Username, Password, Email, _userModel);
          yield return register;
  
          if (register.Success)
          {
              if (RegisterAsTrainer) 
                  yield return new ApplyRoleToUserResult(Username, "Trainer", _userModel);
              yield return new NavigateResult(new Uri("/MainPageViewModel", UriKind.Relative));
          }
          else ErrorMessage = register.ErrorMessage;
      }
  </code></pre>
  
  <p>The code in the DomainService (which sometimes throws an exception)</p>
  
  <pre><code>    [Invoke]
      public void CreateUser(string username, string password, string email)
      {
          Membership.CreateUser(username, password, email);
      }
  </code></pre>
  
  <p>...where Membership is the ASP.NET class, which I am using for membership management.</p>
  
  <p>The IResult that calls the above service (some details elided for clarity):</p>
  
  <pre><code>    public void Execute(ActionExecutionContext context)
      {
          ErrorMessage = null;
          Success = false;
  
          var ctx = new TrainingContext();
          ctx.CreateUser(_username, _password, _email, CreateUserCallback, null);
      }
  
      private void CreateUserCallback(InvokeOperation invokeOp)
      {
          if (invokeOp.HasError)
              invokeOp.MarkErrorAsHandled();
  
          Completed(this, new ResultCompletionEventArgs
              {
                  Error = invokeOp.Error,WasCancelled = invokeOp.IsCanceled
              });
      }
  </code></pre>
  
  <p>The IResult.Completed <strong>DOES</strong> fire, but the rest of the method never executes. I'm literally tearing my hair out with this, please please help me.</p>