Tuesday, June 25, 2013

SharePoint 2010 Content Type Issues

I've been working on a project where I had two document libraries (one upload library and one archive library) and a number custom Site Content Types. We have an event receiver on the upload library that will sometimes move the document (using the C# API SPListItem.File.MoveTo method) to the archive library.

Here's what we saw happening:

We had content type Child which was based on content type Parent. When in the upload library, the document was categorized as Child. When the event receiver moved it to the archive library it would arrive as content type Parent. This made no sense!

We stepped through the code and there was nothing at all that indicated a problem with our event receiver. It was truly happening inside the MoveTo function, so it seems to be a SharePoint bug.

Our only solution was to change recreate the Child content type (as Child2)so that it didn't inherit from Parent and instead inherited from something else (like document). Once we created Child2, we then changed all the documents of Child to Child2. Then we removed the Child content type from both libraries, and deleted the site content type. Finally we renamed the Child2 site content type, and then the instances of that content type in each libary.

Problem solved!

Friday, June 7, 2013

User Profile Synchronization Service Hangs on Starting (SharePoint 2013)

I was recently setting up User Profile Sync Service in SharePoint 2013 and of course, I was faced with the hung on starting issue.

In the past I've used Bill Daugherty's excellent post on resolving the hanging issue for SharePoint 2010, so I figured I'd give it a try for 2013, and it worked!

Thanks Bill!

Tuesday, June 4, 2013

Deploy Globally vs Deploy by Web Application SharePoint 2010

I've been working on a SharePoint 2010 solution for a client that is currently in UAT and we've been deploying bug fixes every other night. The solution includes some site scoped features and was always deployed Globally in our development environment. This was never a problem.

Once we moved to UAT and deployed the solution to our Stage environment we found deploying the solution took almost 40 minutes. This stage environment contains two Web Front Ends as well as a few web applications.

So I began looking into how I could get this solution which contained only site scoped features, to deploy to only our web application.

Everything I read said that a modification to the manifest.xml was the answer, specifically adding in SafeControl entries that will be added to the web.config file of that web application.

We're using Visual Studio 2012, so I figured there had to be some way that I could get VS to create these entries automatically.

The solution was to open up the Package folder of my project and then double click the Package.package and go to the Advanced tab. I then went through each assembly I had and Clicked the Edit button. Low and behold, there was the Safe Controls section. I clicked the button that let me add a new one, typed in the Namespace and Assembly Name for each assembly and then pressed OK (VS had OK greyed out until I moved my cursor focus outside of the Safe Controls section for some reason).

Now, even when I deploy from Visual Studio in my development environment, my solution gets deployed to only my web application! I was then able to use a PowerShell script with the -WebApplication flag to deploy it much faster in our Stage environment.