Building Silverlight solution with RIA service enabled fails on SharePoint 2010 SP1 Environments
This post is a contribution from Raghavendra Nanjaiah, an engineer with the SharePoint Developer Support team.
On a SharePoint 2010 SP1 environment when you try to build Silverlight 4 or 5 solution with the following settings:
- Create a new “Silverlight Application” project.
- Host the Silverlight application in a new web site (default selected).
- Silverlight version = Silverlight 4.
- Check ON “Enable WCF RIA Services”.
- Open SilverlightApplication.Web project.
- Right-click References and add Microsoft.SharePoint.dll.
- Ensure “Configuration Manager” for the solution is set to “Any CPU”.
- Build the entire solution.
It fails with the following error:
For better readability here’s the complete error:
The "CreateRiaClientFilesTask" task failed unexpectedly.
System.Web.HttpException (0x80004005): Could not load file or assembly 'Microsoft.Sharepoint.Sandbox' or one of its dependencies. An attempt was made to load a program with an incorrect format. ---> System.Configuration.ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Sharepoint.Sandbox' or one of its dependencies. An attempt was made to load a program with an incorrect format. ---> System.BadImageFormatException: Could not load file or assembly 'Microsoft.Sharepoint.Sandbox' or one of its dependencies. An attempt was made to load a program with an incorrect format.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
Here’s the workaround we used to fix this issue.
1. Copy Microsoft.SharePoint.Sandbox.dll from GAC to local drive.
Path: “%windir%\assembly\GAC_64\Microsoft.Sharepoint.Sandbox\14.0.0.0__71e9bce111e9429c”
2. Add reference of the copied Microsoft.SharePoint.Sandbox.dll from GAC to SilverlightApplication1.web.
3. Set “Local Copy” property of the Microsoft.SharePoint.Sandbox.dll to “false”.
4. Build the solution.
Hope this was helpful!
Comments
- Anonymous
May 02, 2013
VS 2010 Framework 3.5 Agregar IIS SQL 2005 Full Microsoft Silverlight 4 Developer Runtime Microsoft Silverlight 4 Tools for Visual Studio 2010 Microsoft Silverlight 4 SDK Microsoft Silverlight 4 Tools Package WCF RIA Services RC Telerik; Tuve el problema por 2 semanas; la solución, en le menú de vs2010 actualizé telerik y listo funcionando I had the problem for 2 weeks, the solution, we un updating vs2010 telerik menu and ready to operate