Question

Hi currently I am trying to check if the Ria Service is available for our OOB application.

 public static void IsServiceReachable(Action onServiceAvailable, Action onServiceUnavailable)
       {
            try {
                DomainContext context = new DomainContext();

                InvokeOperation<bool> invokeOperation = context.IsAlive();
                invokeOperation.Completed += (s, arg) => onServiceAvailable();
            }
            catch (Exception) {
                onServiceUnavailable();
            }
        }

When the exception happen my App hangs, and is now just a white screen. Am I doing it correctly?

I am also using MEF in the app, I am lazy importing my views, sadly when Ria Service is not reachable, MEF doesnt import my views :( I am calling CompositionInitializer.SatisfyImports(this).

[ImportMany(AllowRecomposition = true)]
public Lazy<BaseUserControl, IViewMetadata>[] Views { get; set; }
Was it helpful?

Solution

Have you tried checking if an error has occured in the OnServiceAvailable callback:

void OnServiceAvailable(object sender, EventArgs e)
{
    InvokeOperation op = sender as InvokeOperation;
    if (op.HasError) {
        Exception exception = op.Error;
        ...
    } else {
        ...
    }
}

You should probably rename OnServiceAvailable something like OnOperationComplete.

You have to handle the errors in the callback - including the 'ServiceNotAvailable' error. Remember this is an asyncronous call - the client does does not wait for the server response before it continues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top