SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
And what about using a simple List<string> instead of Collection? – Ruben Herman Jul 31 '12 at 12:53
Same. Also with a simple array. – Rafał Saltarski Jul 31 '12 at 12:56
up vote 1 down vote accepted

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.

share|improve this answer
This is what I ended up doing. Bizarre. Thank you for the hint. – Rafał Saltarski Jul 31 '12 at 13:10
I don't know if it's relevant, but I did blog about a similar issue:… – Andy Burns Jul 31 '12 at 14:09

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

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

share|improve this answer
Nope, same thing. – Rafał Saltarski Jul 31 '12 at 13:10

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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