Serialization in SandBoxSolutions
-
Sunday, June 27, 2010 2:06 PM
Hi,
I am building a SnadBox solution webPart that will store some data in SPWeb properties using spweb.AddProperty method.
I have build a custom configuration class and marked as serializable:
[Serializable]
public class MyConfig
{
public long size {get;set;}
public string text {get;set;}
}
I get the SPWeb from the current context but when calling web.AddProperty("Key",new MyConfig()) I get the following error:
System.Runtime.Serialization.SerializationException was unhandled Message=Unable to find assembly ....
The method works just fine if I add the primitives dirrectly as string and long but not when I am trying to serialize my class.
It does seems like the serialization mechanism can't find the assembly so I wonder how the WF will find the assembly when is going to serialize/dehidrade.
Please advise.
My current solution would be to write methods that will manually serialize/deserialize the config class into a string but will require more code.
All Replies
-
Sunday, June 27, 2010 4:21 PMIs the MyConfig class defined in another dll ?
Serge Luca; blog: http://sergeluca.spaces.live.com Devoteam Belgium -
Sunday, June 27, 2010 9:51 PMthe Myconfig class is in the same dll with the webpart and is the only dll in the solution.
-
Monday, August 09, 2010 7:32 PM
Hi,
I think you have found the solution and blogged it as well.:)
http://fmuntean.wordpress.com/2010/06/29/serialization-inside-sandbox-solutions/
Wonderful!! Adding this for the community, hoping your work helps others.
Thanks,
VarunMa-MSFT

