The SharePoint CSOM assemblies and the “The specified module could not be found” error

When working on my community project SharePoint Client Browser I received multiple times the issue which related to the error message “The specified module could not be found”. The error log shows the error is thrown while authenticating with SharePoint Online.

File '' not found, check log file for detailed information. System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.EnsureInited() at Microsoft.SharePoint.Client.Idcrl.ManagedIdcrl.LogonIdentity(String username, SecureString password) at Microsoft.SharePoint.Client.SharePointOnlineCredentials..ctor(String username, SecureString password) at SPBrowser.Entities.TenantAuthentication.InitClientContext()

What is weird about this, although a FileNotFoundException is thrown, the exception details do not indicate which file is actually missing. #Fail!

What also did not help with resolving my issue was missing automated packaging of the SharePoint Client Browser tool. This is definitely one of those reasons to automate your build process. To ensure the package contains everything it needs, instead of missing a single file due to manual packaging.

So, we do we actually need? When building a solution based on the SharePoint CSOM we require a set of assemblies. Depending we are building for SharePoint 2013 (v15) or SharePoint Online (v16) we need a different set. But what was causing the issue was not one of the CSOM assemblies!

Required assemblies for both SharePoint v15 and v16:

  • MSOIDCLIL.DLL
  • MSOIDRES.DLL

SharePoint CSOM assemblies:

  • Microsoft.SharePoint.Client.dll
  • Microsoft.SharePoint.Client.Runtime.dll
  • Microsoft.SharePoint.Client.Taxonomy.dll

Whatever you release in a package, make sure you include the MSOIDCLIL.DLL and MSOIDRES.DLL assemblies!

SharePoint Client Browser v1.2, get it while it’s hot!

The release is out since January 13th, but didn’t got the time to write about it. I have released a new version of the SharePoint Client Browser 2013 (#SPCB). It supports new nodes like associated Visitor, Member and Owner groups of a web object and showing the User Custom Actions for site, web and list object.

But the biggest investment is around User Profiles! Check out this post below.

Enjoy this new version of the SharePoint Client Browser and show your gratitude by adding a review on this page. Download can be found here.

SharePoint Client Browser - Main Screen - v1.2

User Profiles support improved!

The biggest update is within the User Profile area. Version 1.1 was limited to only showing the current user’s properties and peers.

SharePoint Client Browser v1.1 support for User Profiles

The new version shows not only the current user, but retrieves other users via the Search CSOM and retrieves their data as well.

SharePoint Client Browser v1.2 extended support for User Profiles

As shown above not only the User Profile properties and Peers are loaded, but lots of new properties is loaded as well allowing to create rich applications who use the User Profile data. Support is based on the Microsoft.SharePoint.Client.UserProfiles namespace and contains per user profile the following information:

  • User Profile properties
  • Peers
  • Direct Reports
  • Extended Managers
  • Extended Reports
  • Followed Tags (only current user)
  • Followers
  • Suggestions (only current user)
  • People Followed by User

Download SharePoint Client Browser

 Download the SharePoint 2013 Client Browser v1.2 here!

Enjoy this new version of the SharePoint Client Browser and show your gratitude by adding a review on this page.

SharePoint Connections Amsterdam 2013 slide deck and Silly Facts demo source code

Last Tuesday and Wednesday the SharePoint Connections Amsterdam 2013 were held in Amsterdam, Netherlands. I did a session on Developing SharePoint 2013 Apps with Visual Studio 2012 and enjoyed it very much.

Besides my session I was on the Ask The Experts team for the DIWUG. Handed out the new edition of the DIWUG SharePoint eMagazine (download for free) and helped people with their questions. At the start of the conference is was quite, but along the way more and more people came up the Ask The Experts panel. Some interesting question, a big thanks for that!

In this article:

Demo 1: Silly Facts SharePoint-hosted App

The Silly Facts demo is about creating a list with silly facts, like the ones below. The list is provisioned in the App web using a Content Type and List Instance artifact.

Site Contents showing the Silly Facts app Default page as part of the app displaying the Facts list instance with generated silly facts 

Once the list is in place I added a App Part (Client Web Part) to the Host web which shows a random fact every time the page gets loaded.

Adding the App Part onto the page (simular like a web part) App Part showing random silly fact on page load

Next to generating silly facts via the JavaScript CSOM a Custom Action is hooked to an Announcement list in the Host web allowing users to easily add new facts to the Facts list.

Extending the context menu via the Custom Action 

Demo 2: Provider-hosted App retrieving data via CSOM and REST

The next demo is extending demo 1 and changing it to a Provider-Hosted app and adding logic for retrieving data with SharePoint via CSOM (Taxonomy) and REST (Search). Changing the SharePoint-Hosted app to a Provider-Hosted app is done in the AppManifest.xml. Here you can change the type and instantly it will ask to generate a Web Project for you.

Next step is adding the chrome which allows you to add a custom menu shown in the top right corner. You can add you own options which integrate with the chrome.

Changing the app type in the AppManifest.xml (in Visual Studio) Provider-Hosted app with chrome and menu customizations (top right corner) 

With everything in place we will retrieve Taxonomy data via the CSOM and perform search queries via the REST API. This is done via code-behind of the Default.aspx on the button click.

After clicking the button "Get Facts" it shows the silly facts with actual data from SharePoint The retrieved data is stored as a facts in the Facts list

Downloads

You can check the slide deck and source if you want. When you have question, please use the comments section below.

Source code is found on Codeplex: https://sillyfacts.codeplex.com/

SharePoint 2013 Client Browser: Now support for Taxonomy and User Profiles

It’s been around 2 months since the last release of the SharePoint 2o13 Client Browser but work has progressed! Today I updated the tool with two new features.

  • Taxonomy support by showing the hierarchy of Term Store, Groups, Term Sets and Terms.
  • Limited support for User Profiles by showing the User Profile of the current user with the related properties and peers.

Download the SharePoint 2013 Client Browser here!

Taxonomy

By using the Microsoft.SharePoint.Client.Taxonomy namespace it’s possible to get the complete hierarchy of the Term Store and even manipulate it.

SharePoint 2013 Client Browser showing the Taxonomy

User Profiles

Next to the Taxonomy SharePoint 2013 client object model is extended with the Microsoft.SharePoint.Client.UserProfiles namespace for interaction with the User Profiles. For now I only included the current user profile. Future releases will be extended with other properties and showing more user profiles of other users within the environment.

SharePoint 2013 Client Browser showing the User Profile of the current user

SharePoint Client Browser 1.0 released, bye bye preview!

Finally after 2 months I decided to build the 1.0 version of SharePoint Client Browser and released it to the community! Although the preview (beta) status did not prevent people from downloading it. The counter is currently set at 555 downloads since start of the project on the 2nd of July (only 2 months ago).

CodePlex project and download at https://spcb.codeplex.com/.

So what got changed? I guess almost everything changed from authentication support for default (username and password), SharePoint Online, anonymous and forms based all the way to almost complete coverage of the Client Side Object Model (CSOM). That’s a bit over the top, but the basics for Foundation are in the tool. New capabilities for future releases will focus on Server components like taxonomy.

Remote PowerShell for SharePoint Online and on-premise

A hidden gem is the PowerShell support. It’s very easy to start a PowerShell session and use CSOM within PowerShell. Meaning remote PowerShell for SharePoint Online (and on-premise of course).

How to?
  • Open SharePoint Client Browser
  • Add a new site collection
  • Select the site collection in the tree view
  • Click the PowerShell-button in the menu bar (or use the context menu)
  • Enter your password (if needed)
  • Start using CSOM in PowerShell

PowerShell support for CSOM PowerShell console with CSOM and SharePoint Online (Office 365)

Some highlights of the tool

Why do you want to use this tool? One reason should be enough, it allows you to speed up your development by providing insights into the CSOM. And much more…

  • Get insight in your site collection structure
  • Find hidden lists, items or documents
  • Discover artifact properties
  • Easily start PowerShell, via context menu, and run (scripted) queries against your remote site collection
  • Support for both SharePoint 2010 and SharePoint 2013
  • Connect to on-premise or SharePoint Online (Office 365) site collections
  • No installer
  • Remote access from your desktop to site collection via Client Side Object Model (CSOM)
    • Can run remote, no need to run on the SharePoint server itself

SharePoint Client Browser for SharePoint 2013

Using CSOM and PowerShell to query SharePoint Online or on-premise

Recently I released the SharePoint Client Browser (preview) that provides inside in a remote SharePoint site by using the Client Side Object Model (CSOM). The tool only reads data and shows it in a rich interface. When you want to make changes you have options: 1) build a custom tool and use the CSOM to interact with SharePoint or 2) use PowerShell and CSOM to interact with SharePoint.

This post shows how to use PowerShell and CSOM together to interact and automate configuration changes to your SharePoint. The example script can be used for both SharePoint Online and on-premise deployments.

This PowerShell script will be a new feature in the SharePoint Client Browser. This allows the user to start PowerShell directly from the SharePoint Client Browser and eliminates the need to do the scripting discussed in this post by yourself!

Prerequisites

Besides having a SharePoint site collection somewhere, you need to create a folder on your local machine. This folder needs to have the SharePoint Client Runtime assemblies. These can be downloaded here. Next to the SharePoint Client Runtime you need to place your scripts here (for example: OpenSite.ps1).

Folder (on local machine) with prerequisites

The PowerShell script

The easiest way to get started is creating a new TXT-file in the local folder and rename it to “OpenSite.ps1” (or choose a more appropriate name). Next right click with your mouse on the file and choose Edit. This will open up the Windows PowerShell ISE and you can start editing your script.

Authentication

The script is pretty easy and almost reusable for both SharePoint Online and on-premise, but it has a difference between them. Guest what it is?! The authentication is done differently. Below 3 different authentication examples.

Current user credentials

By not providing any credentials automatically the current user credentials are used.

SharePoint Online

When connecting to SharePoint Online you can use the new SharePointOnlineCredentials class. This makes it a lot easier then with SharePoint 2010.

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($loginname, $pwd)

SharePoint (on-premise) and credentials

Setting the credentials is done via the NetworkCredential class. That looks like this:

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $ctx.Credentials = New-Object System.Net.NetworkCredential($loginname, $pwd)

The full example script

Below you can find the PowerShell script to use with SharePoint Online. Make sure when using the script you choose the right authentication model (see above). After running this script you can use the CSOM the same way as you would use CSOM in your C# application.

$loc = "C:\Users\Bram\Downloads\SharePoint" # Location of DLL's $siteUrl = "https://contoso.sharepoint.com" $loginname = "bram@contoso.onmicrosoft.com" Set-Location $loc Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.dll") Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Runtime.dll") Write-Host "Please enter password for $($siteUrl):" $pwd = Read-Host -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) # Remove or replace line below to change authentication method $ctx.Credentials = New-Object System.Net.NetworkCredential($loginname, $pwd) $web = $ctx.Web $ctx.Load($web) $ctx.ExecuteQuery() Write-Host " Current web title is '$($web.Title)', $($web.Url)"

SharePoint Client Browser (preview) released

Last Saturday I introduced the SharePoint 2013 Client Browser (preview) tool during my session on SharePoint Saturday Holland 2013. I’ve got some enthusiastic feedback and now it’s time to finally release the preview version!

Remote SharePoint development is getting more important. Especially with SharePoint Apps. To speed up development, find hidden lists/items/documents, discover the structure or specific artifact properties use the SharePoint Client Browser which supports both SharePoint 2010 and SharePoint 2013.
This WinForm tool does not need installation but simply unzip the download and start the EXE file. Next step, connect to your on-premise or Office 365 site collection.

More information and download: https://spcb.codeplex.com/

SharePoint 2013 Client Browser