Tuesday, January 18, 2011

Unexpected Response: System.ServiceModel.ServiceActivationException

Had a SharePoint site migrated from MOSS 2007 to SharePoint 2010 via the content DB detach/re-attach method. Not sure that was a factor here, but adding this little fact for posterity.

Problemo:

Editing a publishing page produced the following popup dialog in IE, FireFox, Chrome, etc when a user attempted to edit a publishing page that was already checked out by another user:

          image

“Unexpected response from server. The status code of the response is ‘500’. The status text of response is ‘System.ServiceModel.ServiceActivationException”

Investigation into the server’s event log showed this helpful tidbit of information:

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/2593506
Exception: System.ServiceModel.ServiceActivationException: The service '/_vti_bin/client.svc' cannot be activated due to an exception during compilation.  The exception message is: Operation is not valid due to the current state of the object.. ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Microsoft.SharePoint.ApplicationRuntime.SPLayoutsMappedFile.MapLayoutsVirtualPath(String virtualPath)
   at Microsoft.SharePoint.ApplicationRuntime.SPVirtualPathProvider.GetCacheKey(String virtualPath)
   at Microsoft.SharePoint.Publishing.Internal.CmsVirtualPathProvider.GetCacheKey(String virtualPath)
   at System.Web.Compilation.BuildManager.GetCacheKeyFromVirtualPath(VirtualPath virtualPath, Boolean& keyFromVPP)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetCompiledCustomString(String virtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.GetCompiledCustomString(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
Process Name: w3wp

Yet more evidence to be used in a future blog post: Why I hate WCF!

Solution-o:

So searching for this issue produces a few results – though none that had the exact ‘Operation is not valid due to the current state of the object’ wording. The results that did come back were ones that were all too familiar when I had made the mistake of using WCF in the past: cannot have multiple bindings, multiple authentication mechanisms, etc. With the solutions generally being along the lines of creating an extended site. Oh boy – another IIS site to manage! 

The deal with this particular site though did not fall in line with those solutions – it only had one binding (single AAM to 443) – though it was anonymous enabled (but not claims-enabled).

So how did I fix? Here are the steps:

  1. Travel to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI on each WFE – or wherever your 14-Hive exists.
  2. Tip: Make a backup copy of the web.config file in that folder. You just never know…
  3. Edit the web.config file by adding the highlighted line to enable aspNetCompatibility:

<configuration>
  <system.web>
      …
     
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

Save your changes – that should be all you need to do. App pool will recycle…

Why does this work? Who the heck knows – ask the WCF team – you may find them working on the Office Assistant 2.0 project. My guess is that things work better (but maybe slower? more limitedly?) when the ASP.NET pipeline joins the party. Will post here if there are any side effects – so far so good though. 

Tuesday, January 11, 2011

SharePoint Saturday Virginia Beach 2011: Source Code

[placeholder for the Google Analytics project associated with my presentation]

Google Analytics works on your Intranet sites

That’s right – tested this out and was able to have a site on my local VM that I made up a name for (dev.schroeder.local – not resolvable outside the VM itself) successfully work with Google Analytics tracking.

image

 

Official word from Google on this: http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55510

 

The important caveats are:

  • You must use the latest version of their tracking code.

    • The latest version is the good async stuff, so this is a good move regardless.

 

  • The site must be accessed with a fully qualified domain name (FQDN).

    • I tried to trick it using the _setDomainName method in the client API, but no dice.
    • If your site does not support access via FQDN, you may need to:
      • Add an alternate access mapping to the site in Central Admin
      • Update DNS
      • Redirect the partial name (http://intranet) to the FQDN (http://intranet.company.local)
        • The URLRewrite Module may be able to help you do this: http://www.iis.net/download/URLRewrite
        • Could also go low tech: Add some script to default page to redirect if document.location is NOT the FQDN (though pages accessed directly would obviously bypass this measure)
        • Maybe move that script to the masterpage…
Monday, January 10, 2011

SharePoint Saturday Virginia Beach 2011

Once again, it was a fantastic event.  Thanks to the organizers for letting hack presenters such as myself present.

http://www.sharepointsaturday.org/virginiabeach/default.aspx

Monday, November 29, 2010

SharePoint 2010–App Pool Account User Rights

This is a quick one: Had a new web application in a new farm – so it was the first time the app pool identity was put to use. The app pool would not start with SQL-sounding errors like ‘Unknown SQL Exception 1346 occurred...Either a required impersonation level was not provided, or the provided impersonation level is invalid’.

So after verifying all of the usual suspects, it was determined that adding the user to the local administrators group resolved the issue. Of course that is not a good solution, so I wanted to find out what the smallest set of user rights should be for that account. In the end (and working well so far), the user is a plain-Jane domain user with these rights:

  • Log on as a batch job
  • Generate security audits
  • Impersonate a client after authentication
Tuesday, August 24, 2010

Cannot activate Document Sets feature in SharePoint 2010

A coworker attempted to activate the Document Sets feature within a SharePoint 2010 site collection. This action resulted in a blank page with the feature still inactive. Hmm… Permissions? But she is a site collection admin!

Having both site collection admin permissions and beyond, I tried it myself and got the same results. Diving into the log files (anyone else find that more informative in SP2010, or is that just me?) I found these lines:

  • Feature Activation: Activating Feature 'DocumentSet'
  • Calling 'FeatureActivated' method of SPFeatureReceiver for Feature 'DocumentSet'
  • DocumentSet FeatureActivating: start
  • DocumentSetTemplate ProvisionLists for 0x999990 on https://site : throws exception: Only a site collection administrator can add a work item.. Stacktrace:    at Microsoft.SharePoint.SPSite.AddWorkItem(Guid gWorkItemId, DateTime schdDateTime, Guid gWorkItemType, Guid gWebId, Guid gParentId, Int32 nItemId, Boolean fSetWebId, Guid gItemGuid, Guid gBatchId, Int32 nUserId, Byte[] rgbBinaryPayload, String strTextPayload, Guid gProcessingId, Boolean useExponentialRetryBackOff)     at Microsoft.SharePoint.SPSite.AddWorkItem(Guid gWorkItemId, DateTime schdDateTime, Guid gWorkItemType, Guid gWebId, Guid gParentId, Int32 nItemId, Boolean fSetWebId, Guid gItemGuid, Guid gBatchId, Int32 nUserId, Byte[] rgbBinaryPayload, String strTextPayload, Guid gProcessingId)     at Microsoft.O...   

Score one for the error handling – an error that was actually caught. But there was nothing really interesting about the information above, aside from the fact that it thought I was not a site collection admin – which I verified. Never know – someone else might have booted me from the group!

It was the next line of the log file, which continued the call stack output, that I found the answer:

  • ...ffice.DocumentManagement.DocumentSets.DocumentSetTemplate.<ProvisionLists>b__0()     at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()     at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)     at Microsoft.Office.DocumentManagement.DocumentSets.DocumentSetTemplate.ProvisionLists().


So the code that was failing was running in the context of the app pool user… interesting.


Resolution

Ensured the app pool identity account was a site collection admin. Document Sets feature then activated without a problem.

So my remaining questions are:

  1. Is it necessary to have the app pool identity be a site collection admin? Is that a best practice? Had this been a production system, I probably would have elevated to site collection admin, activated the feature, then removed the account from the site collection admin group.
  2. Why the heck is RunElevated needed in the activation code of a Site Collection feature?? Isn’t that a security risk – or at least a good extra validation that the current user has permissions to do what they are attempting to do?
Monday, June 7, 2010

SharePoint 2010 Quick Tip: Expose the Enterprise Wiki Template

Was looking to create a shiny new SP 2010 wiki site as a subsite. I could see the Enterprise Wiki template when creating a new site collection, but not when attempting to create a child site of an existing site collection. In MOSS 2007, I do not recall a situation where the “Wiki Site” template was not available, so I was surprised when I found that I was missing the option to create a new SP 2010 wiki site – aka Enterprise Wiki.

The answer is pretty easy – though may not be 100% obvious: Activate the SharePoint Server Publishing Infrastructure feature on the site collection:

image

Once that is active, when you attempt to create a new site in a site collection where the publishing infrastructure is activated, the Enterprise Wiki template will be an option.

I went back to check: Activating the publishing Infrastructure feature in MOSS 2007 is not a requirement for the Wiki Site template. With all the new bling that comes with the 2010 wiki, it is reasonable that it would have more dependencies on other SharePoint components.

 
© I caught you a delicious bass.
Back to top