I'm trying to port a farm solution to a sandboxed one, and I can't figure out how to port this piece of code:

public partial class vClockPartSB : System.Web.UI.WebControls.WebParts.WebPart
    public Collection<String> ClockTimeZones { get; set; }
    public int NumberOfClocks { get; set; }
    public string DdlMain { get; set; }
    public string DdlSubOne { get; set; }
    public string DdlSubTwo { get; set; }
    public string DdlSubThree { get; set; }
    public string DdlSubFour { get; set; }

    protected override void OnInit(EventArgs e)
        ClockTimeZones = new Collection<string>();

I get the following error:

Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: Web part property 'ClockTimeZones' uses unsupported type (System.Collections.ObjectModel.Collection`1[[System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]]), and cannot be run as a sandboxed code web part.

How should I approach it?

  • And what about using a simple List<string> instead of Collection? Jul 31, 2012 at 12:53
  • Same. Also with a simple array. Jul 31, 2012 at 12:56

3 Answers 3


I would be tempted just to store a string - rather than a collection of strings - and perform my own serialisation/deserialisation. Probably using the string.Split() function and a suitable delimiter.


The System.Collections.ObjectModel namespace is not allowed in the Sandbox.

For your scenario, could you use the List< string > instead?


Apparently, only the following types are supported as the properties of the web part in the sandbox solution:

  • string
  • bool
  • Enum
  • short
  • int
  • Guid
  • Uri
  • byte
  • char
  • long
  • float
  • decimal
  • double

Here is a link to Alan Dahl's blog article where Alan Dahls' blog did the search.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.