Custom macro error: Method for object of type 'System.Int32' not found, please check the macro or th

Kenny Deblaere asked on October 26, 2018 13:07

Hello

I have following custom Macro method setup

[MacroMethod(typeof(bool), "Comment ", 2)]
[MacroMethodParam(0, "id", typeof(int), "Comment")]
[MacroMethodParam(1, "number", typeof(int), "Comment")]
public static object Method(EvaluationContext context, params object[] parameters)
{
    // Method
}

When I run the Macro, I'm getting following error: Method for object of type 'System.Int32' not found, please check the macro or the method declaration.

Is there something wrong in my setup?

Kind regards

Kenny

Correct Answer

Kenny Deblaere answered on October 26, 2018 15:28

I've found the solution.

Calling Method(ToInt(123),456) did fix the issue.

0 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on October 26, 2018 13:33

I assume you've followed the docs: docs.kentico.com/.../registering-custom-macro-methods

Have you also registered them?

And the code us supplied your macro will be called literally as Method(123,456), as I expect you want something as GetComment(123,456)?

0 votesVote for this answer Mark as a Correct answer

Kenny Deblaere answered on October 26, 2018 13:37 (last edited on October 26, 2018 13:38)

Hi David

I've registered my MacroMethodContainer as

[assembly: RegisterExtension(typeof(CustomMacroMethods), typeof(int))]

I've been following the documentation.

The Container is places in another project.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.