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 8052145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:28:25+00:00 2026-06-05T07:28:25+00:00

I have the following Code and web method: public class RaumklassenHelper { internal static

  • 0

I have the following Code and web method:

public class RaumklassenHelper
{
   internal static Array Raumklasse()
   {
       List<object> raumKlassenObject = new List<object>();

       using (SqlConnection con = new SqlConnection(@"Data Source=Localhost\SQLEXPRESS;Initial Catalog=BOOK-IT-V2;Integrated Security=true;"))
       using (SqlCommand cmd = new SqlCommand(@"SELECT BEZEICHNUNG, BEZEICHNUNG_EN FROM RAUMKLASSE", con))
       {
           con.Open();
           using (SqlDataReader rdr = cmd.ExecuteReader())
           {
               while (rdr.Read())
               {
                   if (rdr["BEZEICHNUNG"] != DBNull.Value && rdr["BEZEICHNUNG_EN"] != DBNull.Value)
                   {
                       raumKlassenObject.Add(new
                           {
                               Name = rdr["BEZEICHNUNG"].ToString(),
                               Name_En = rdr["BEZEICHNUNG_EN"].ToString()
                           });
                   }
               }
           }
       }
       return raumKlassenObject.ToArray();
   }
}



 [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
   [WebMethod]
   public Array Raumklasse()
   {
       return RaumklassenHelper.Raumklasse();
   }

I’m getting an Error if I try to Invoke the Method:

This is the first time the error occured.

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: &lt;&gt;f__AnonymousType0`2[System.String,System.String] cannot be serialized because it does not have a parameterless constructor.
   at System.Xml.Serialization.TypeDesc.CheckSupported()
   at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
   at System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(Type type)
   at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write6_ArrayOfAnyType(Object o)
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
   at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)
   at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
   at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
   at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
   at System.Web.Services.Protocols.WebServiceHandler.Invoke()
  • 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-05T07:28:26+00:00Added an answer on June 5, 2026 at 7:28 am

    Try using object[] as return type instead of Array


    for the other issue:

        public class RaumklassenHelper
    {
    
            public class RAUMKLASSE
            {
                public string Name { get; set; }
                public string Name_En { get; set; }
            }
    
    
            internal static List<RAUMKLASSE> Raumklasse()
       {
           List<RAUMKLASSE> raumKlassenObject = new List<RAUMKLASSE>();
    
           using (SqlConnection con = new SqlConnection(@"Data Source=Localhost\SQLEXPRESS;Initial Catalog=BOOK-IT-V2;Integrated Security=true;"))
           using (SqlCommand cmd = new SqlCommand(@"SELECT BEZEICHNUNG, BEZEICHNUNG_EN FROM RAUMKLASSE", con))
           {
               con.Open();
               using (SqlDataReader rdr = cmd.ExecuteReader())
               {
                   while (rdr.Read())
                   {
                       if (rdr["BEZEICHNUNG"] != DBNull.Value && rdr["BEZEICHNUNG_EN"] != DBNull.Value)
                       {
                           raumKlassenObject.Add(new RAUMKLASSE()
                               {
                                   Name = rdr["BEZEICHNUNG"].ToString(),
                                   Name_En = rdr["BEZEICHNUNG_EN"].ToString()
                               });
                       }
                   }
               }
           }
           return raumKlassenObject;
       }
    }
    
    
    
     [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
       [WebMethod]
       public List<RAUMKLASSE> Raumklasse()
       {
           return RaumklassenHelper.Raumklasse();
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
I have the following code: SPList list = web.Lists[this.ListName]; SPListItem item = list.Items.Add(); now
I have the following controller @Controller @RequestMapping(/project/view.html) public class ProjectViewController { private static final
ASP.NET 4.0 Webforms project. I have the following in my code-behind. public partial class
Assume that I have the following object public class MyClass { public ReadOnlyDictionary<T, V>
I Have following code with LINQ var q = (from web in DataContext.Webs select
i have the following piece of code my my web.config: <customErrors mode=On defaultRedirect=~/Exception.aspx enableVersionHeader=false>
I currently have the following section of HTML code from a web page: <td
I have an ASP.NET web site with something similar to the following code: .aspx
I am writing code to performance test a web site. I have the following

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.