Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:47:23+00:00 2026-06-10T01:47:23+00:00

I am trying to pass an object via WCF. I can pass strings ,

  • 0

I am trying to pass an object via WCF. I can pass strings, ints etc no problem, but this list of objects will not work.

Here are my 2 specific errors:

Error 1:

The best overloaded method match for
 'test.ServiceReference1.JobsClient.FilesToControl(test.ServiceReference1.Item[])'
 has some invalid arguments

Error 2:

Argument 1: cannot convert from 'System.Collections.Generic.List<test.Site1.Item>'
 to 'test.ServiceReference1.Item[]'

This is the function I am trying to call within asp.net:

// Commit the files
ServiceReference1.JobsClient Client = new ServiceReference1.JobsClient();
Client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://" +   DropDownListSystems.SelectedValue + ":8732/FactoryAudit/");
test.ServiceReference1.ReturnClass ControlFiles_Result;
ControlFiles_Result = Client.FilesToControl(lstNewItems);

lstNewItems (the object I am trying to pass) is defined as the following code:

List<Item> lstNewItems = new List<Item>(); // Control Items  

Item is defined as:

public class Item
{
    public Item(string Paramater, string Type)
    {
        _Paramater = Paramater;
        _Type = Type;

    }

    private string _Paramater;

    public string Paramater
    {
        get { return _Paramater; }
        set { _Paramater = value; }
    }

    private string _Type;

    public string Type
    {
        get { return _Type; }
        set { _Type = value; }
    }
}

Now in the WCF service I have the following function which accepts a list of items:

//Files Manager
public  ReturnClass FilesToControl(List<Item> ItemsToControl)

{
return new ReturnClass(1, String.Empty, String.Empty, null, null, null);
}

The service contract is defined as:

[ServiceContract]
public interface IJobs
{
     //Files Manager
     [OperationContract]
     ReturnClass FilesToControl(List<Item> ItemsToControl);      
}

The items class is defined in WCF as follows:

[DataContract]
[KnownType(typeof(List<Item>))]
[KnownType(typeof(Item))] 
public class Item
{
   public Item(string Paramater, string Type)
   {
       _Paramater = Paramater;
       _Type = Type;

   }
   [DataMember]
   private string _Paramater;
   [DataMember]
   public string Paramater
   {
       get { return _Paramater; }
       set { _Paramater = value; }
   }
   [DataMember]
   private string _Type;
   [DataMember]
   public string Type
   {
       get { return _Type; }
       set { _Type = value; }
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:47:24+00:00Added an answer on June 10, 2026 at 1:47 am

    What’s lstNewItems in your asp code?

    To work it should be an Item[]. Even though you take a List<Item> in the WCF code, the default settings for proxy code generated by WCF is to use arrays for collections.

    Edit

    With the latest edit in place, the problem is possible to find:

    The error message shows that the FilesToControl proxy method accepts an array (Item[])

    Error 1 The best overloaded method match for
    ‘test.ServiceReference1.JobsClient.FilesToControl(test.ServiceReference1.Item[])’
    has some invalid arguments

    You pass in a List<Item>:

    List<Item> lstNewItems = new List<Item>();
    //....
    ControlFiles_Result = Client.FilesToControl(lstNewItems);
    

    There are three ways to fix this.

    • Change lstNewItems to be of type Item[] instead.
    • Change the settings of the service reference (which you’ve added to be able to call your WCF) to use List<T> as the default collection type.
    • Change the call to convert to an array.

    The latter can be done through a call to ToArray:

    ControlFiles_Result = Client.FilesToControl(lstNewItems.ToArray());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass a complex object via Windows Communication Foundation, but I get
I was trying to pass a string object to System.out.printf(...) in Java, but I
In javascript, I have an object that I am trying to pass but not
I'm trying to pass an object like that <% if( can? :change, comment.karma, comment.user_id)%>
I've been trying to pass an object to my main thread process but it
I'm trying to pass an object from one controller action to another. The object
I'm trying to pass a JavaScript object to a PHP script through jquery.ajax() ,
I am trying to pass a simple JSON object to a controller using MVC3
I'm trying to pass a dynamic, user created object through AJAX to some C#.
The following is the custom class, whose object I am trying to pass: package

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.