0

I have a list of a class I made called MonitoringItem.

public class MonitoringItem
    {
        public int URLID { get; set; }
        public string URL { get; set; }
        public List<String> RequestHeaders { get; set; }
        public string RegexMatchString { get; set; }
        public string CheckType { get; set; }
        public string ExpectedResponseCode {get; set;}
    }

When I try to consume this on the client side, using a service reference I get:

Error   1   Cannot implicitly convert type 'WebMonitor.GetURLsToMonitor.MonitoringItem[]' to 'System.Collections.Generic.List<WebMonitor.GetURLsToMonitor.MonitoringItem>'  \\home\d\Source\Projects\WebMonitor\WebMonitor\WebMonitorProgram.cs 44  17  WebMonitor

This is my client code:

List<GetURLsToMonitor.MonitoringItem> m = new List<GetURLsToMonitor.MonitoringItem>();

GetURLsToMonitor.ws_GetURLsToMonitorSoapClient g = new GetURLsToMonitor.ws_GetURLsToMonitorSoapClient();
 m = g.GetURLsToMonitor(); <--This is where it is giving me the error

.

I'm not returning an array so not sure why it's saying this.

Dan C.
  • 559
  • 3
  • 8
  • 26
  • Also, my web service wraps the class in a list here: public List GetURLsToMonitor() – Dan C. Feb 25 '15 at 16:40
  • Change the properties of your service reference to materialize collections as lists instead of arrays. You might even need to remove and re-add the reference with the proper settings. – D Stanley Feb 25 '15 at 16:41
  • Arrrgh that was it. Not sure how I missed that. Thank you!!! – Dan C. Feb 25 '15 at 16:50

0 Answers0