I’ve got the unenviable task of cleaning up a rather messy VB.Net client. The general plan is to move all calculations to WebServices, and I can see exactly how to do this, but it involves passing a large number of different variables to the WebServices.
I chose to use an ArrayList as I’ve worked with them heavily in Java, and have had no issues passing ArrayLists between the C# (ASMX) WebService and a C# client (Windows Forms-based).
However, the VB.Net client app doesn’t want to pass the ArrayList into the WebServices, giving a compiler error “Value of type ‘System.Collections.ArrayList’ cannot be converted to ‘1-dimensional array of Object’.”
Thanks to everyone who helped but I managed to find the answer. The issue relates to VB.Net’s handling of WebService object passes; nothing to do with the C#.
As ck said, I had to call ‘.ToArray()’ on the ArrayList when I passed it to the WebService, but then had to use ‘AddRange()’ on a fresh ArrayList to get the results into it. Code is as follows:
Or generically: