However comment is always "Foo" (message box shows "Not Allowed"), so it appears that the ByRef modifier is not working
It is, but you're using it incorrectly, with incorrect expectations :)
When you create the argument array, you're copying the value of comment
into the array. After the method has completed, you no longer have access to the array, so you can't see that it's changed. That change in the array won't affect the value of comment
, but demonstrates the ByRef
nature. So what you want is:
Dim arguments As Object() = New Object() { 1234, comment }
method.Invoke(_scriptClass, arguments)
Debug.WriteLine(arguments(1))