none
Custom Workflow Activity: NullReferenceException during build RRS feed

  • Question

  • I am new to FIM 2010 R2, and new to .NET programming.  I am getting a NullReferenceException when trying to build my custom activity library, and I'm hoping someone can give me some pointers for what to check.

    I started with a library that our consultant left us that contained four custom activities.  (It builds just fine, of course.)  One of the activities sets a user attribute to a future date (default = 30 days in the future) to support faculty offboarding.  I am trying to add a similar activity to set some related user attributes to support student offboarding.  Using both the consultant's activity as an example as well as the walkthrough for creating a custom logging activity I created a SequenceActivity in VS2010 with the new classes to support the activity and a corresponding UI.

    When I try to build the solution, I get the error "Cannot create activity of type <my new activity class>.  System.NullReferenceException...".  The last thing in what appears to be a stack trace is "<my new activity class>..ctor()" .  It says it's in column 1 of line 1 of a file "WFActivityLibrary", which happens to be the assembly's title but NOT the assembly name.  It's also the name of the folder holding the solution and source files but NOT the name of any actual file.  When I double-click the error, it tells me that the file doesn't exist.

    Thanks in advance, -Les

    Sunday, March 31, 2013 6:35 PM

Answers

All replies

  • What's in the constructor of your activity?

    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    • Marked as answer by Les LaCroix Monday, April 1, 2013 8:30 PM
    Monday, April 1, 2013 2:59 PM
    Moderator
  • The constructor is:

            public SetStudentSlideDates()
            {
                InitializeComponent();
            }
    

    where InitializeComponent was generated by the designer, included below for completeness.

            #region Designer generated code
    
            /// <summary> 
            /// Required method for Designer support - do not modify 
            /// the contents of this method with the code editor.
            /// </summary>
            [System.Diagnostics.DebuggerNonUserCode]
            [System.CodeDom.Compiler.GeneratedCode("", "")]
            private void InitializeComponent()
            {
                this.CanModifyActivities = true;
                System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                this.UpdateUser = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
                this.InitializeUpdateUser = new System.Workflow.Activities.CodeActivity();
                this.ReadUser = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
                this.InitializeReadUser = new System.Workflow.Activities.CodeActivity();
                this.ReadCurrentRequest = new Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity();
                // 
                // UpdateUser
                // 
                this.UpdateUser.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
                this.UpdateUser.ApplyAuthorizationPolicy = false;
                this.UpdateUser.Name = "UpdateUser";
                this.UpdateUser.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
                this.UpdateUser.UpdateParameters = null;
                // 
                // InitializeUpdateUser
                // 
                this.InitializeUpdateUser.Name = "InitializeUpdateUser";
                this.InitializeUpdateUser.ExecuteCode += new System.EventHandler(this.InitializeUpdateUser_ExecuteCode);
                // 
                // ReadUser
                // 
                this.ReadUser.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
                this.ReadUser.Name = "ReadUser";
                this.ReadUser.Resource = null;
                this.ReadUser.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
                this.ReadUser.SelectionAttributes = null;
                // 
                // InitializeReadUser
                // 
                this.InitializeReadUser.Name = "InitializeReadUser";
                this.InitializeReadUser.ExecuteCode += new System.EventHandler(this.InitializeReadUser_ExecuteCode);
                // 
                // ReadCurrentRequest
                // 
                activitybind1.Name = "SetStudentSlideDates";
                activitybind1.Path = "CurrentRequest";
                this.ReadCurrentRequest.Name = "ReadCurrentRequest";
                this.ReadCurrentRequest.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity.CurrentRequestProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
                // 
                // SetStudentSlideDates
                // 
                this.Activities.Add(this.ReadCurrentRequest);
                this.Activities.Add(this.InitializeReadUser);
                this.Activities.Add(this.ReadUser);
                this.Activities.Add(this.InitializeUpdateUser);
                this.Activities.Add(this.UpdateUser);
                this.Name = "SetStudentSlideDates";
                this.CanModifyActivities = false;
    
            }
    
            #endregion
    

    Monday, April 1, 2013 6:59 PM
  • My generated code includes a reference to an ActivityBind that is missing in the code from our consultant.  One of the ways I deviated from the walkthrough was in the use of dependency properties, as the consultants code did not use them.  What is that ActivityBind, and is it an indication that part of the code thinks I'm using dependency properties?

    Monday, April 1, 2013 7:25 PM
  • It must have been that.  I built things (again), but this time I had the generated code open.  When some component in the code got to looking like the working example from the consultant, I stopped editing the activity in the designer and went on to the next.

    Thanks, Brian.  I was assuming that it would be more difficult to get the designer to create code that didn't work...

    Monday, April 1, 2013 8:30 PM