Cook Computing

XML-RPC.NET, VB, and Arrays

June 12, 2002 Written by Charles Cook

Quite coincidentally a problem with VB and arrays was discussed on the XMLRPCNET Yahoo group today. A VB implementation of a proxy method included the following line:

[codemp] Dim param(1) As Object [/code]

This unexpectedly (for a C# coder at least) defines an array with two elements so when you write:


param(0) = New String(name)

you end up with null in the second element. This was causing the Invoke method of XmlRpcClientProtocol to throw an exception. The array in this case should be defined as:


Dim param(0) As Object

Dr GUI.NET's article has a section on this difference between VB.NET and C# which warns:

his differences causes problemsit's especially nasty when the dimension is a variable, particularly if that variable is passed between routines written in different languages. The result is that your arrays can be sized differently than you expect, leading to nasty off-by-one errors and null-pointer reference exceptions.