Follow Me

How to use ‘Microsoft.SharePoint.Publishing’ assembly in a Sandboxed Solution

By Stefan Feenstra   /     Aug 01, 2013  /     SharePoint 2013  /     2 Comments

When you try to use the ‘Microsoft.SharePoint.Publishing.dll’ in your sandboxed solution you will get the following error:

You could still use the benefits of ‘Microsoft.SharePoint.Publishing.dll’. First download the tool ILSpy (ILSpy is a free .NET Assembly Browser and decompiler). With this tool it’s possible to view the content of this dll file.

For example you would like to configure the associated content type of a page layout programmatically :

Normal solution with Microsoft.SharePoint.Publishing

var exampleContentType = new SPContentType(…
var examplePageLayout = new PageLayout(…
examplePageLayout.AssociatedContentType = exampleContentType;

Solution without Microsoft.SharePoint.Publishing

  1. Load the ‘Microsoft.SharePoint.Publishing.dll’ in ILSpy
  2. Search for the ‘PageLayout’ class
  3. Search for the property ‘AssociatedContentType’
  4. This property contains the following code:

  5. Now when you click on the FieldId.AssociatedContentType reference you will see this is a Guid that references to a field in SPListItem

  6. Conclusion: you could also write:

    var examplePageLayoutListItem = new SPListItem(…
    var AssociatedContentType = new Guid(“b510aac1-bba3-4652-ab70-2d756c29540f”);
    examplePageLayoutListItem[AssociatedContentType] = exampleContentType;
    examplePageLayoutListitem.Update();

Now you don’t need to use the Microsoft.SharePoint.Publishing dll in your solution. (Also working on SharePoint Online)
This was just a very small example of what you can do with the Microsoft.SharePoint.Publishing dll in a Sandboxed Solution.

Continue Reading

Never install SharePoint 2013 on a Domain Controller

By Stefan Feenstra   /     Jul 18, 2013  /     SharePoint 2013  /     3 Comments

Please keep in mind when you want to create a Single Server installation of SharePoint 2013 that you don’t install SharePoint 2013 on a Domain Controller. Some features of SharePoint 2013 don’t work when you install it on the Domain Controller. Today I found one:

When I tried to activate my Sandboxed Solution on my single server SharePoint 2013 installation it failed with the following error:

An attempt to connect to the remote activator failed with exception 'System.Runtime.Remoting.RemotingException: Cannot resolve 'channel' template reference: 'http client'.

An attempt to connect to the remote activator failed with exception ‘System.Runtime.Remoting.RemotingException: Cannot resolve ‘channel’ template reference: ‘http client’.

Then I tried to activate the same solution on a SharePoint 2013 installation with a seperate domain controller server and it worked! And when you leave the feature event receiver commented out it’s also working on the single server installation.

Continue Reading