Could not load file or assembly ‘Microsoft.Sharepoint.Sandbox, Version=14.0.0.0
Could
not load file or assembly ‘Microsoft.Sharepoint.Sandbox,
Version=14.0.0.0, …………..
Posted: June 25, 2013 in SharePoint 2010, Technical Diary
Tags: 'Microsoft.Sharepoint.Sandbox, Could not load file or assembly, DLL Erro, SharePoint2010, Version=14.0.0.0
Tags: 'Microsoft.Sharepoint.Sandbox, Could not load file or assembly, DLL Erro, SharePoint2010, Version=14.0.0.0
Assembly
error in ASP.Net Web Application during Run Time
“Could
not load file or assembly ‘Microsoft.Sharepoint.Sandbox, Version=14.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies.
An attempt was made to load a program with an incorrect format.”
Issue
I created an ASP.Net Web Application. I added a reference to the “Microsoft.SharePoint.dll”. I needed this to use some of the SharePoint Server Object Model assemblies.
I created an ASP.Net Web Application. I added a reference to the “Microsoft.SharePoint.dll”. I needed this to use some of the SharePoint Server Object Model assemblies.
On investigating I found that a
“Microsoft.Sharepoint.Sandbox.dll” was created in the bin folder of my Web
application.
An instinctive though that
would come to the mind of all would be – “I have not added a reference to this
dll, then what is it doing in my bin folder”. Then naturally we go ahead and
delete it, with a hope that the problem is solved.
But lo and behold! When we
build our solution, a new copy of the dl is recreated in our bin folder. So the
problem remains as is.
Root Cause
I am not sure, but it appears that when we reference the “Microsoft.SharePoint.dll” , on running the application, the assemblies in this dll, internally reference the “Microsoft.Sharepoint.Sandbox.dll”.
I am not sure, but it appears that when we reference the “Microsoft.SharePoint.dll” , on running the application, the assemblies in this dll, internally reference the “Microsoft.Sharepoint.Sandbox.dll”.
Please note this is my analysis and
understanding only.
Solution
Hence we see we should not be deleting this dll, it simply won’t work. We would need this dll and its assemblies to fully make use of the Server Object Model.
Hence we see we should not be deleting this dll, it simply won’t work. We would need this dll and its assemblies to fully make use of the Server Object Model.
The most effective and logical
solution is to make a local copy of this dll and add a reference to it in our
Web Application.
Here are the steps that I
followed –
Step 1
Make a copy of the Microsoft.SharePoint.Sandbox.dll from GAC to the local drive.
In the ‘Run’ use the following script –
Make a copy of the Microsoft.SharePoint.Sandbox.dll from GAC to the local drive.
In the ‘Run’ use the following script –
%windir%\assembly\GAC_64\Microsoft.Sharepoint.Sandbox\14.0.0.0__71e9bce111e9429c
Step 2
Add a reference to this local copy of the dll, in your web application.
Add a reference to this local copy of the dll, in your web application.
Step 3
Set the “copy to local” property to False.
Set the “copy to local” property to False.
Step 4
Build and Run the project.
Build and Run the project.
It should work fine now.
Comments
Post a Comment