Friday, March 8, 2013

"Microsoft.Practices.SharePoint.Common" for SharePoint 2013

Can't find the SharePoint 2013 version at the moment, so I compiled one through Visual Studio 2012 on SharePoint 2013.

Below contains the source code and assemblies, you can download it here.

Source files:


Assemblies and WSP files:


[Update, 2013-03-11]

During test, I got the error below.

System.MethodAccessException: Attempt by security transparent method 'Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrentFarmLocator()' to access LinkDemand protected method 'Microsoft.Practices.SharePoint.Common.SharePointEnvironment.get_CanAccessSharePoint()' failed.  Methods must be security critical or security safe-critical to satisfy a LinkDemand.
   at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrentFarmLocator()
   at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.DoGetCurrent()
   at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrent()

In terms of here, Security Transparency in .NET 4 is changed.

I cannot find a simple solution to fix the problem, so I removed all method attributes "[SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]".

You can download the source code and assemblies from here:



  1. This comment has been removed by the author.

  2. Hi! I've been using the original code and your (less secure) version for years now.
    A customer has been complaining about the fact that his values stored at a farm level using the IHierarchicalConfig implementation are not updated at site level.
    I found there is a bug in the SPFarmPropertyBag. It doesn't handle the cache interval properly in the GetSettingStore() method. In the first IF, it compares the lastLoad, but in the second IF it doesn't.
    The SPWebAppProperyBag has the correct code. I downloaded your version of the source code again, fixed it and deployed it: Customer happy = me happy ;-)

    Thank you for source code!!

    Regards, Wouter Heesakkers

  3. Thanks Eric for this. We are running into the same issue. I looked at your RAR file and there are multiple DLLs in there. Can you point me to the DLL that we can deploy on our sharepoint servers to see if this problem goes away?

    1. This is for developers, and should only be used as a "draft".

      If any error pop up, you need to debug and then fix it.

      (I need to know much, much more details and test to figure out the cause.)

  4. I seem to get this error even when running the site in 2010 compatibility mode. Any thoughts on why?