How do I configure a Sharepoint Emulator for use with the Sharepoint Servicelocator

May 6, 2014 at 12:08 AM
On the serface this seems like a match made in heaven but I cannot figure out how to configure my emulator so that the service locator dopes not throw a exception. I am setting up the service locator, then using the SharepointEmulatationScope(Enabled) and then setting

ShimSPListItem.AllInstances.ContentTypeGet = (b) => new ShimSPContentType { NameGet = () => string.Empty };
ShimSPListItem.AllInstances.WebGet = (c) => new ShimSPWeb
                                                 {
                                                     CurrentUserGet = () => new ShimSPUser(),   
                                                  };
Finally I call SharePointServiceLocator.GetCurrent();

where I receive the following error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Practices.SharePoint.Common.ServiceLocation.NoSharePointContextException: SPFarm was not found.
Result StackTrace:
at Microsoft.Practices.SharePoint.Common.Configuration.SPFarmPropertyBag..ctor(SPFarm farm)
at Microsoft.Practices.SharePoint.Common.Configuration.FullTrustPropertyBagHierarchy.BuildHierarchy(SPWeb web)
at Microsoft.Practices.SharePoint.Common.Configuration.FullTrustPropertyBagHierarchy..ctor(SPWeb web)
at Microsoft.Practices.SharePoint.Common.Configuration.HierarchyBuilder.GetHierarchy(SPWeb web)
at Microsoft.Practices.SharePoint.Common.Configuration.ConfigManager.GetHierarchy()
at Microsoft.Practices.SharePoint.Common.Configuration.ConfigManager.GetPropertyBag(ConfigLevel level)
at Microsoft.Practices.SharePoint.Common.ServiceLocation.ServiceLocatorConfig.GetPropertyBag()
at Microsoft.Practices.SharePoint.Common.ServiceLocation.ServiceLocatorConfig.GetConfigData()
at Microsoft.Practices.SharePoint.Common.ServiceLocation.ServiceLocatorConfig.GetTypeMappings()
at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.CreateServiceLocatorInstance(SPSite site)
at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.DoGetCurrent(SPSite site)
at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.DoGetCurrent()
at Microsoft.Practices.SharePoint.Common.ServiceLocation.SharePointServiceLocator.GetCurrent()
at BrookfieldGrs.OE.Web.Mvp.ClientWebParts.ClientWebPartsPresenterBase`1.GetServiceLocator()