Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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:

[ToolboxItem(false)]
public partial class vClockPartSB : System.Web.UI.WebControls.WebParts.WebPart
{
    [Personalizable(PersonalizationScope.User)]
    public Collection<String> ClockTimeZones { get; set; }
    [Personalizable(PersonalizationScope.User)]
    public int NumberOfClocks { get; set; }
    [Personalizable(PersonalizationScope.User)]
    public string DdlMain { get; set; }
    [Personalizable(PersonalizationScope.User)]
    public string DdlSubOne { get; set; }
    [Personalizable(PersonalizationScope.User)]
    public string DdlSubTwo { get; set; }
    [Personalizable(PersonalizationScope.User)]
    public string DdlSubThree { get; set; }
    [Personalizable(PersonalizationScope.User)]
    public string DdlSubFour { get; set; }



    protected override void OnInit(EventArgs e)
    {
        ClockTimeZones = new Collection<string>();
        base.OnInit(e);
        InitializeControl();
    }

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=2.0.0.0, 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

2 Answers 2

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
1  
I don't know if it's relevant, but I did blog about a similar issue: novolocus.com/2012/04/05/… –  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

Your Answer

 
discard

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.