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

  • Home
  • SEARCH
  • 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 553181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:34:42+00:00 2026-05-13T11:34:42+00:00

possible duplicate: Cannot serialize parameter of type ‘System.Linq.Enumerable… ’ when using WCF, LINQ, JSON

  • 0

possible duplicate:
Cannot serialize parameter of type ‘System.Linq.Enumerable… ’ when using WCF, LINQ, JSON


Hi,

If my method signiature looks like this, it works fine.

[WebGet]
MyClass[] WebMethod()

If the signiature looks like this

[WebGet]
IEnumerable<T> WebMethod()

I get the following error:
Cannot serialize parameter of type ‘X.Y.Z.T+<WebMethod>d__2c’ (for operation ‘WebMethod’, contract ‘IService’) because it is not the exact type ‘System.Collections.Generic.IEnumerable`1[X.Y.Z.T]’ in the method signature and is not in the known types collection. In order to serialize the parameter, add the type to the known types collection for the operation using ServiceKnownTypeAttribute.

I have tried adding.
ServiceKnownType(typeof(IEnumerable))

Same error.

Is this a bug in 2010 beta 2, or is this likely to be correct going forward?

Thanks

  • 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-05-13T11:34:42+00:00Added an answer on May 13, 2026 at 11:34 am

    The iterator types generated by the C# compiler are not serializable and never will be.

    If you read this page, you’ll see that it wouldn’t make sense to serialize the iterator.

    You need to return an array.

    EDIT: The simplest way to do that is to move your iterator to a seperate method, and change WebMethod to

    [WebGet]
    MyClass[] WebMethod() { return OtherMethod().ToArray(); }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: non static method cannot be referenced from static context hey i have
Possible Duplicate: WCF Service Deployment in IIS Page cannot be displayed and how does
Possible Duplicate: Fatal error: Cannot use object of type stdClass as array in Please
Possible Duplicate: Cannot install R-forge package using install.packages Has anyone gotten the latest version
Possible Duplicate: How come millisUntilFinished cannot detect exact CountDownTimer intervals? Why does using the
Possible Duplicate: Are there problems that cannot be written using tail recursion? From my
Possible Duplicate: Cache Object in PHP without using serialize So I have built a
Possible Duplicate: What is the reason behind “non-static method cannot be referenced from a
Possible Duplicate: The query results cannot be enumerated more than once? I am using
Possible Duplicate: Can we override static method in Java? We cannot override the static

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.