Author Archives: Stu

Run With Elevated Privilges

SharePoint Short #20 Instead of explicitly wrapping code in a RunWithElevatedPrivileges block, it’s better to first check if the user has sufficient privileges and only elevate when they don’t. Instead of: SPSecurity.RunWithElevatedPrivileges(() => { // elevated code… });SPSecurity.RunWithElevatedPrivileges(() => { … Continue reading

Posted in SharePoint, SharePoint Shorts | Tagged | Leave a comment

Cannot invoke HTTP DAV request

When using the Client-Side Object Model (CSOM) for SharePoint and you’re trying to create\overwrite a file using binary data, you’d naturally try and use the SaveBinaryDirect method of the File class: public void SaveFile(Microsoft.SharePoint.Client.ClientContext context, Microsoft.SharePoint.Client.File file, string relativeItemUrl, byte[] … Continue reading

Posted in CSOM, SharePoint | Tagged , | 2 Comments

Creating Entities from Dynamic SQL

When working with a LINQ to SQL model (dbml) and you try to add a custom stored procedure that uses dynamic SQL, you will likely see an error similar to the following: The return type for the following stored procedure … Continue reading

Posted in SQL, Visual Studio | Tagged , | Leave a comment

Get SearchServiceApplication in PowerShell

In C# when retrieving the default SearchServiceApplication object you might do something like the following, if you were trying to initiate a new Schema object, for example: SPServiceContext serviceContext = SPServiceContext.GetContext(SPContext.Current.Site);   SearchServiceApplicationProxy searchApplicationProxy = serviceContext.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;   Guid … Continue reading

Posted in SharePoint | Tagged , , | Leave a comment

Custom_AddDocLibMenuItems

SharePoint Short #19 When implementing your own Custom_AddDocLibMenuItems, which allows you to add custom menu items to the ECB of SharePoint items, remember to check for other implementations of this method before your own version. For example: function YourImplementationOf_AddDocLibMenuItems(m, ctx, … Continue reading

Posted in SharePoint, SharePoint Shorts | Tagged , | 4 Comments