Debugging Windows Service Tip

This is a quick tip on debugging Windows services or anything that runs as a seperate thread.  In other words, if you have to attach to that process to debug it, and you have the source code, the following tip will make it easy to debug.

A Windows service usually runs automatically, it is designed to run as a continuous service and, therefore, spawns one or more threads to do the actual work. This happens very quickly. As such, it is difficult to attach to the process (Alt+P) in time to properly debug the service and attach during a specific part of the execution. As a multi-threaded app, it becomes cumbersome and painful to debug. Fortunately since Visual Studio 2015 that we can vote invoke that allows us to attach to the process through the Visual Studio just-in-time debugger. It’s super simple, call:

System.Diagnostics.Debugger.Launch();

Use this call anywhere in your code where you want the code to break into Visual Studio.  It will invoke a Visual Studio just-in-time debugger prompt:

Visual Studio 2015 Just-In-Time Debugger
Visual Studio 2015 Just-In-Time Debugger

Make your selection and debug.  Happy coding my friends.

For more information: https://msdn.microsoft.com/en-us/library/cktt23yw.aspx

Build a SP2013 Content Enrichment Service

Hi, yes it has been a while. Its been a brutal year.  I now have 4 girls, two recent twins. Probably doubled the gray hairs on my head by now.  Had to move to a bigger home.  Had to get a minivan to accommodate the bigger family. After moving into the house, I have been fixing things for 3 months now … an still not done.  There’s much more as well. Nonetheless, here I am … now to CEWS (Content Enrichment Web Service).

So there are many articles out there, between several I was able to get something working. Lets start with the basics:

  • Content Enrichment is a process by which you can add/modify/enhance metadata to the search index directly.
  • Content Enrichment does not add metadata to the actual document or list item.
  • Content Enrichment only works for on-premise farms.  Thus, not Office 365.
  • Content Enrichment is deployed as a web service.
  • Content Enrichment can be great if done properly … poor code will slow down search very significantly.

The basic steps for creating and deploying a CEWS are:

  1. Using Visual Studio 2012 or 2013, create a WCF Service Application project.
  2. Create your Content Enrichment Service
    1. Implement the IContentProcessingEnrichmentService interface from the Microsoft.Office.Server.Search.ContentProcessingEnrichment assembly which you must reference (located at c:\Program Files\Microsoft Office Servers\15.0\Search\Applications\External\microsoft.office.server.search.contentprocessingenrichment.dll by default; unless you installed SharePoint somewhere else).
  3. Register your Content Enrichment Service with Powershell
    1. http://msdn.microsoft.com/en-us/library/office/jj163983%28v=office.15%29.aspx
  4. Test and Validate
  5. Once satisfied, package your solution
  6. Deploy your solution to Azure or IIS (or elsewhere as you need).

Here a couple other resources for more information:

  • How to: Use the Content Enrichment web service callout for SharePoint Server
    http://msdn.microsoft.com/en-us/library/office/jj163982%28v=office.15%29.aspx

  • Custom content processing with the Content Enrichment web service callout
    http://msdn.microsoft.com/en-us/library/office/jj163968%28v=office.15%29.aspx

 

Change the global SharePoint 2013 Label

Hi All,

Something I find very useful when working with clients is to help them distinguish each environment between development (DEV), testing (TEST), Staging (STAGE) and Production (PROD). Some clients may have even more environments.  Lets take a look at the change in the UI first…

This is the Out of the Box label (Before):

SharePoint Label Out of the Box

 

This is the customized label (After):

SharePoint Label modified

 

So how do we do it, we use PowerShell to change the label at the web application level:

Add-PSSnapin *share*
$webapp = Get-SPWebApplication http://bcdevsp2013
$webapp.SuiteBarBrandingElementHtml = “SharePoint DEV”;
$webapp.Update();

I hope this comes in handy.  It is a subtle thing, but very helpful throughout the application lifecycle.

Cheers,

Brian

PS – Happy New Years to everyone.