Activity could not be loaded because of errors in the xaml

Meysam Karimi 1 Reputation point
2023-01-01T08:45:56.347+00:00

Hi, I try to write the Windows Work Flow tutorials' examples. The created activities work when I run the examples, but when I need to change them via Designer, I see the "Activity could not be loaded because of errors in the xaml" error message on some components. I couldn't resolve the issue till now. I tried to load the XAML file to troubleshoot it via the below code:

 try  
            {  
                XamlServices.Load("C:\\User\\CMMS\\Windows Work Flow Examples\\CreateAnActivity\\NumberGuessWorkflowActivities\\StateMachineNumberGuessWorkflow.xaml");  
            }  
            catch (Exception e) {  
                Console.WriteLine(e.StackTrace);  
                throw e;  
            }  

And I saw the below message in the program's console:

An unhandled exception of type 'System.Xaml.XamlObjectWriterException' occurred in NumberGuessWorkflowHost.exe  
Additional information: No matching constructor found on type 'System.Activities.Activity'. You can use the Arguments or FactoryMethod directives to construct this type.  
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
42,721 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Meysam Karimi 1 Reputation point
    2023-01-02T11:33:53.413+00:00

    I found the below description from link :

    XAML Load Errors
    When an activity fails to load, a red box with the text "Activity could not be loaded because of errors in the XAML" appears. This typically occurs when the activity's type cannot be resolved. The invalid activity can be deleted in the designer by selecting the red box and deleting it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.