Reducing the amount of markup in ASCX files
If you are using the Visual Studio 2010 SharePoint Power Tools and you are adding many controls to your ASCX file, you may see the following error message.
Warning 19 The custom tool 'SharePointWebPartCodeGenerator' failed. There was an error deserializing the object of type Microsoft.VisualStudio.SharePoint.Commands.CommandParameter. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 197, position 21. <MyASCXPath> <MyProjectName>
The guidance is to reduce the size of the ASCX file by completing these steps.
- Move JavaScript and CSS out of the .ASCX file to reduce the amount of markup in the .ASCX.
- Deploy the scripts and CSS to a library in the site collection containing the sandboxed web part.
- Leverage the code-behind model to generate UI elements rather than embed in the .ASCX.
Or, you can install the Visual Studio 2010 Service Pack 1 to remove this error.