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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:37:16+00:00 2026-05-13T22:37:16+00:00

I am having a minor problem with WCF service proxies where the message contains

  • 0

I am having a minor problem with WCF service proxies where the message contains List<string> as a parameter.

I am using the ‘Add Service reference’ in Visual Studio to generate a reference to my service.

   // portion of my web service message
   public List<SubscribeInfo> Subscribe { get; set; }
   public List<string> Unsubscribe { get; set; }

These are the generated properties on my MsgIn for one of my web methods.
You can see it used ArrayOfString when I am using List<string>, and the other takes List<SubscribeInfo> – which matches my original C# object above.

[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
public System.Collections.Generic.List<DataAccess.MailingListWSReference.SubscribeInfo> Subscribe {
    get {
        return this.SubscribeField;
    }
    set {
        if ((object.ReferenceEquals(this.SubscribeField, value) != true)) {
            this.SubscribeField = value;
            this.RaisePropertyChanged("Subscribe");
        }
    }
}

[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
publicDataAccess.MailingListWSReference.ArrayOfString Unsubscribe {
    get {
        return this.UnsubscribeField;
    }
    set {
        if ((object.ReferenceEquals(this.UnsubscribeField, value) != true)) {
            this.UnsubscribeField = value;
            this.RaisePropertyChanged("Unsubscribe");
        }
    }
}

The ArrayOfString class generated looks like this. This is a class generated in my code – its not a .NET class. It actually generated me a class that inherits from List, but didn’t have the ‘decency’ to create me any constructors.

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.Runtime.Serialization.CollectionDataContractAttribute(Name="ArrayOfString", Namespace="http://www.example.com/", ItemName="string")]
    [System.SerializableAttribute()]
    public class ArrayOfString : System.Collections.Generic.List<string> {
    }

The problem is that I often create my message like this :

client.UpdateMailingList(new UpdateMailingListMsgIn()
{
    Email = model.Email,
    Name = model.Name,
    Source = Request.Url.ToString(),
    Subscribe = subscribeTo.ToList(),
    Unsubscribe = unsubscribeFrom.ToList()
});

I really like the clean look this gives me.

Now for the actual problem :

I cant assign a List<string> to the Unsubscribe property which is an ArrayOfString – even though it inherits from List. In fact I cant seem to find ANY way to assign it without extra statements.

I’ve tried the following :

  • new ArrayOfString(unsubscribeFrom.ToList()) – this constructor doesn’t exist 🙁
  • changing the type of the array used by the code generator – doesn’t work – it always gives me ArrayOfString (!?)
  • try to cast List<string> to ArrayOfString – fails with ‘unable to cast’, even though it compiles just fine
  • create new ArrayOfString() and then AddRange(unsubscribeFrom.ToList()) – works, but I cant do it all in one statement
  • create a conversion function ToArrayOfString(List<string>), which works but isn’t as clean as I want.

Its only doing this for string, which is annoying.

Am i missing something? Is there a way to tell it not to generate ArrayOfString – or some other trick to assign it ?

  • 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-13T22:37:16+00:00Added an answer on May 13, 2026 at 10:37 pm

    Any .NET object that implements a method named “Add” can be initialized just like arrays or dictionaries.

    As ArrayOfString does implement an “Add” method, you can initialize it like this:

    var a = new ArrayOfString { "string one", "string two" };
    

    But, if you really want to initialize it based on another collection, you can write a extension method for that:

    public static class U
    {
        public static T To<T>(this IEnumerable<string> strings)
            where T : IList<string>, new()
        {
            var newList = new T();
            foreach (var s in strings)
                newList.Add(s);
            return newList;
        }
    }
    

    Usage:

    client.UpdateMailingList(new UpdateMailingListMsgIn()
    {
        Email = model.Email,
        Name = model.Name,
        Source = Request.Url.ToString(),
        Subscribe = subscribeTo.ToList(),
        Unsubscribe = unsubscribeFrom.To<ArrayOfString>()
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an minor problem using sql server 2008. When I go for
I am having a minor problem with segue using push in Xcode's storyboards. Its
I'm having a minor problem and I don't know how to do it. I
Having a minor problem, I'm trying to create an about us dialog box by
been a while since i used flash... the minor problem im having is that,
I'm relatively new to Rails development and I'm having a minor associations problem. I'd
I'm having a (minor) problem here. I'm calling a named template and am assigning
I am having a slight apache problem. It's probably something so minor that I
I'm working with jQuery's .get() function and I'm having a very weird problem using
I'm having a minor problem with Mixed-content on HTTPS served pages on our site,

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.