1
Vote

Non-Static field requires a target.

description

I am working through the interactive shell example. The Prompt built in command returns the following error:

Non-Static field requires a target.

This is being generated in FluentHelper.cs , Class FluentHelpers, Function SetDataMemberValue, line 229 on in the instruction field.SetValue(null, value);

I'm not sure what the correction for this issue is. Please advise.

Thanks,

Dinsdale

comments

dinsdale247 wrote May 20, 2013 at 5:26 AM

Sorry, forgot to say it's version 1.4 (stable). I also receive the same error running the prompt command in my own application running against the binaries from NuGet.

vfabregat wrote Aug 29, 2014 at 10:56 AM

Are you triying to assign a value to a parameter?

Something like this:
    public sealed class AddCommand : CommandBase
    {
        public static string Pattern;

      /..../

        public override IEnumerable<ShellArgument> GetArguments()
        {
            yield return AddArgument()
                /.../
                .AssignTo(() => Pattern);
        }
/.../
If the answer is yes, maybe the error is because your property, in this case
Pattern
has to be a static property.

I hope this help you (yeah, I know is a old issue)