Share via


Error message in WF4: "The argument of type '' cannot be used. Make sure that it is declared on an activity."

The following error might occur when an activity executes:

The argument of type '<type>' cannot be used. Make sure that it is declared on an activity.

If the type above refers to an implementation child, then it's possible that it's being created in the Execute method of the activity. If this is the case, try moving it to the CacheMetadata method- this is the method that tells the runtime about the implementation details of the activity. Adding an implementation child during the Execute method is too late- the runtime won't be aware of the member at this point.

Incorrect:

 protected override void Execute(CodeActivityContext context)



{



    this.body.Input = new InArgument<Message>(this.intermediateMessage);



    this.body.Output = new OutArgument<Message>(this.intermediateMessage);





}

Correct:

 protected override void CacheMetadata(NativeActivityMetadata metadata)



{



    this.body.Input = new InArgument<Message>(this.intermediateMessage);



    this.body.Output = new OutArgument<Message>(this.intermediateMessage);





}