Displaying Error Messages in C# Components

When I write a C# Script in Grasshopper, it displays a list of error messages as a list in the “out” parameter. How do I generate a list of error messages from a component I make in Visual Studio? Currently it only says “One runtime error” but it does not provide a line number.

Hi @stevescott517,

Have you tried the method AddRuntimmeMessage? It provides a nice way to output specific messages in “bubble” above the component and will change component color depending on how critical is the runtime message.

Hope this helps


That part is only available if the message came from an Exception, and if the assembly was compiled with sufficient debug information to find associated line numbers. But the good news is you do not need line numbers for your own custom components, like @Xavier_Ayme said, using AddRuntimeMessage you can send any number of informative messages (both warnings, errors and comments) to the message stack.

Do note that the same message never appears more than once, so if you want to see exactly how often a specific message is triggered from within a loop or something, you’ll have to change it for each iteration.

Thank you for the help.