If the typeInstance could not be cast to LegacyDialogTask, trying to set additionalValues caused a null exception. Inserted a null check and then cast to ITaskReturnUrl instead to get the returnUrl.
If the typeInstance could not be cast to LegacyDialogTask, trying to set additionalValues caused a null exception. Inserted a null check and then cast to ITaskReturnUrl instead to get the returnUrl.