Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Cannot convert from system...IList<class> to class[]</class>

Cannot convert from system...IList<class> to class[]</class>

Scheduled Pinned Locked Moved C#
helpcsharpdatabasewcflinq
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sevententh
    wrote on last edited by
    #1

    Please could somebody help... My brains gone dead :doh: I'm trying to pass the following to a wcf service

    public IList<tbItem> GetItemsWhereIn (IList<tbClass> iclass)
    {
    iServiceClient svc = new iServiceClient();
    IList<tbItem> list = svc.FindItems(iclass);

    return list;
    }

    The problem is passing parameter iclass to svc.FindItems error Cannot convert from system...IList<tbClass> to tbClass[] The wcf service is setup as

    public interface iService{
    [OperationContract]
    List<tbItem> FindItems(IList<tbClass> iclass);}

    And the linq query as

    public List<tbItem> FindItems(IList<tbClass> iclass)
    {
    ...linq code working correctly
    }

    If you could point the way I would be very greatful :-D

    K 1 Reply Last reply
    0
    • S Sevententh

      Please could somebody help... My brains gone dead :doh: I'm trying to pass the following to a wcf service

      public IList<tbItem> GetItemsWhereIn (IList<tbClass> iclass)
      {
      iServiceClient svc = new iServiceClient();
      IList<tbItem> list = svc.FindItems(iclass);

      return list;
      }

      The problem is passing parameter iclass to svc.FindItems error Cannot convert from system...IList<tbClass> to tbClass[] The wcf service is setup as

      public interface iService{
      [OperationContract]
      List<tbItem> FindItems(IList<tbClass> iclass);}

      And the linq query as

      public List<tbItem> FindItems(IList<tbClass> iclass)
      {
      ...linq code working correctly
      }

      If you could point the way I would be very greatful :-D

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      I think you need to tell the Client Service Reference to generate the Client proxy using genertic Lists rather than arrays (Lists<T>, IList<T> and other collection types are normally sent up and down the wire as T[] unless you tell the service reference to generate the proxy with something else:

      1. Right click your service reference
      2. Select Configure Service Reference
      3. In the Collection Type drop down select System.Collections.Generic.List

      Note that you can't set the Value to IList<T> as Services don't play well with Interfaces / OO in general.

      CCC solved so far: 2 (including a Hard One!)

      S 1 Reply Last reply
      0
      • K Keith Barrow

        I think you need to tell the Client Service Reference to generate the Client proxy using genertic Lists rather than arrays (Lists<T>, IList<T> and other collection types are normally sent up and down the wire as T[] unless you tell the service reference to generate the proxy with something else:

        1. Right click your service reference
        2. Select Configure Service Reference
        3. In the Collection Type drop down select System.Collections.Generic.List

        Note that you can't set the Value to IList<T> as Services don't play well with Interfaces / OO in general.

        CCC solved so far: 2 (including a Hard One!)

        S Offline
        S Offline
        Sevententh
        wrote on last edited by
        #3

        Thanks for answer, this did the trick I just needed to then change this line

        IList list = svc.FindItems(iclass.ToList());

        :-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups