Debugging uSync in Umbraco 7.3

uSync is a tool in Umbraco which allows developers to create a file system version of their Umbraco database. Using source control teams of developers can quickly share database updates without swapping db backups back and forth. uSync does a fairly good job of it as well, but there are times when uSync hits an error and dies somewhat violently. Usually you can piece together which content sync is causing the error and go from there, but other times… well…


We can see there is something going on with the propertyData/propertyType foreign key constraint, but beyond that we do not know which content item is conflicting with uSync. We have a few options: A) delete all local content and import all, B) export from local to overwrite the conflict from source control, or C) guess until it works. None of those options sound too appealing, and someone is probably losing their content in the process (if anyone has another way to debug this kind of error please comment below)

The fourth option I came up with is to run the SQL profiler while uSync is running to pinpoint the exact SQL command that is throwing the error. To do this, open the SQL Server Profiler under the Tools dropdown and switch tabs to the Events Selector. Uncheck all of the pre-checked boxes and check the following:

trace log 1 trace log 2 trace log 3

Click Run to begin. Now return to the Umbraco backoffice and run the sync. When the error pops up again click the Pause button in the SQL profiler. Locate the red line which looks like this:

trace error

This will be the same error you saw in the usync window in the backoffice. Above this line is a trace log called “RPC:Starting”. This is the sql command that was executed when the error was thrown. Clicking this reveals some more information:

trace sql

Now we have found the culprit! “delete from cmsPropertyType where contentTypeId = 5412”. Back to SQL Server, let’s run a select all from cmsPropertyType where contentTypeId=5412

sql property type

That is the line that uSync is trying to delete, let’s look for the entry in cmsPropertyData that is blocking us from removing that line. Run a “select from cmdPropertyData where propertyTypeId = 414” and you will see several entries that match up. I forgot to take a screenshot at this point, but what I found in dataNvarchar was the json format to a grid editor that I had been using in previous versions of a content item. Delete these entries and run uSync again, this time it should work! (or hit another error)

So what is going on here? The page that broke was originally using a document type which had a grid editor, but due to changing requirements we needed to change document types to one which did not have one. Umbraco does not delete the propertyData entry because they are trying to maintain content versioning, which is still tied to the content item. When uSync attempted to sync my updates to the content item with what was in the file directory it does not delete the old versions in cmsPropertyData before attempting to delete the cmsPropertyType.

(Views: 51)

Multi-level site headers

The objective is to handle headers for a main site and several smaller micro sites. Each microsite will have multiple pages which should display the micro-site header. Unpublished content should not be displayed

public PartialViewResult Header()
    //AncestorOrSelf in IContent
        var pageId = UmbracoContext.PageId;
        var item = Services.ContentService.GetById(pageId.Value);

        //Check current Item for "Site Components" folder.
        var siteComp = item.Children()
            .FirstOrDefault(m => m.Published 
                && m.ContentType.Alias == "folderSiteComponents");

        //If current item does not have it, then search ancestors
        if (siteComp == null)
            siteComp = item.Ancestors()
            .Select(m => m.Children()
                .FirstOrDefault(n => n.Published 
                    && n.ContentType.Alias == "folderSiteComponents"))
            .LastOrDefault(m => m != null);

        //Once folder is found, check its children for an item named "Header".
        var header = siteComp.Children()
            .Where(m => m.Published && m.ContentType.Alias == "ciHeader")
            .Select(m => _glassService.CreateType<Header>(m))
        return PartialView("~/Views/Partials/_Header.cshtml", header);
    catch (Exception e)

    return PartialView("~/Views/Partials/_Header.cshtml");

(Views: 26)

SP2013 JSLink issue

I began working with SP2013 about a month ago, and one of the new features included in this iteration of SharePoint is JSLink. I began researching and found some very helpful blogs and articles explaining how it works and providing examples for its use. I immediately dove in to try it in my own environment.

The first example i tried was from This is a very basic example which replaces every word in a specific column with the word “Animal”. So i create a custom list, add a new column (taking advantage of the new quick edit feature), and give each item some unique values. Finally I drop the list view web part on a new page i made to test on. After setting up the JSLink to point to my JS file, i clicked save and waited for the magic to happen… Only when it loaded, nothing happened. All of the values in that column were unchanged!

So what happened? I scoured the internet to find anything that might give me a clue as to what happened. I found people having issues with the minimal download strategy, mismatches on the field name they were targeting and the internally stored field name, and certain column types that do not allow custom JSLink rendering.

That last one though… that kind of stuck out to me. The column i had created wasn’t made in the list settings but in the quick edit grid view. To be honest i had no idea how it was being created in the background. I created two more columns, one using an existing site column “Categories” and another created column called “Category”.

Final result is both traditionally created column worked perfectly, while the quick edit column is not recognized. What a headache.

(Views: 245)

Useful Information on Data Contracts

I’m beginning to learn about the C# attributes [DataContract] and [DataMember]. Data Contracts in C# are a loose set of rules that are defined for a client and server to communicate through, C# has built in Data Contracts defined for default classes such as ints, strings, etc. Before .NET 3.5 SP1 any custom class, structure or enumerable object would require adding an attribute [DataContract] to the object definition; as well as adding [DataMember] to each property that would need to be serialized to XML.

I found a post on stack overflow which brings up a good question, and an even better reply. I feel the original author did a fine job of explaining it, so I felt linking to the post and grabbing a screen shot would do them more justice than paraphrasing.

The original link.


And the response


(Views: 297)

Statement Keywords Fixed, Checked and Unchecked

Fixed Block Type

C# uses a garbage collector to clean up memory leaks and take care of unused data storage variables. Fixed ensures that the variable declared inside it’s block will not be touched by the garbage collector. Because this presents a potential issue with memory leaks the fixed keyword block can only be used in methods declared with the “unsafe” keyword. This requires special permissions that some systems will block. The following is an example from MSDN.

unsafe static void TestMethod()

    // Assume that the following class exists. 
    //class Point  
    //    public int x; 
    //    public int y;  

    // Variable pt is a managed variable, subject to garbage collection.
    Point pt = new Point();

    // Using fixed allows the address of pt members to be taken, 
    // and "pins" pt so that it is not relocated.

    fixed (int* p = &amp;pt.x)
        *p = 1;


Checked Block Type

The checked block type is used to make the compiler check for overflow values on any integer calculations. This is useful when performing an operation on a variable and assigning the result to an integer. The compiler does not detect overflow values on non-static variables, so the checked code block is required to enforce it. Here is a code sample from MSDN.

// If the previous sum is attempted in a checked environment, an  
// OverflowException error is raised. 

// Checked expression.
Console.WriteLine(checked(2147483647 + ten));

// Checked block. 
    int i3 = 2147483647 + ten;

Unchecked Block Type

The unchecked block type will allow an integer assignment to overflow instead of throw an error. An example of this from MSDN. The resulting int1 will be equal to “-2,147,483,639”

    int1 = 2147483647 + 10;
int1 = unchecked(ConstantMax + 10);

(Views: 272)

Password changes on SharePoint service accounts

If a SharePoint service account’s password changed in AD it may not change in SharePoint. This can cause the account to lock out from AD and, if it is a user account as well, can lock a user out of the network every time that service is called. While it is not a good idea for user accounts to be service accounts or Managed Accounts, it is not uncommon for a development environment to be set up in this way. If this happens execute the following in an administrator Management Shell:

STSADM.EXE -o updatefarmcredentials -userlogin domain\username -password password

This will update the credentials stored in SharePoint.

(Views: 315)

Fix for Chrome browser errors in SharePoint

I found this amazing piece of advice a few days ago to completely fix all issues Chrome has running SharePoint. Here is the link to Royal Tutorials, all credit goes to them for this fix.

The common issues I have seen using Chrome with SharePoint have been with the scrolling and the ribbon row. This is caused in part to how SharePoint renders scrolling/ribbon row and in part how Chrome loads scripts.

SharePoint has invested heavily in their Ribbon UI across most of their products, and SharePoint is no different. They want this easily accessible no matter where on the page you are. To handle that they are overriding the browser native scroll function and using JavaScript to position the page and page elements. Additionally they have JavaScript load events to enable buttons and functions on the ribbon row.

In SharePoint most controls loaded on the ribbon are disabled, and once it passes SharePoint security then the scripts are loaded for that control. If the browser attempts to load the scripts before the control is enabled the control will never be loaded. Internet Explorer loads all scripts in order before executing them, so IE works very will with SharePoint. Chrome on the other hand loads script files as it receives them which results in controls never becoming active.

The solution Royal Tutorials suggests is to add a little logic to the master page.

<script type=”text/javascript”>
window[addEventListener ? ‘addEventListener’ : ‘attachEvent’](addEventListener ? ‘load’ : ‘onload’, function(){

The window adds an event listener for an “attachEvent”. It checks if the _spBodyOnLoadWrapper has been loaded yet or not, and if it hasn’t then it calls the load function before the “attachEvent” executes.

That’s it! Six lines of JavaScript to your master page and you have cross browser functionality in SharePoint 2010.

(Views: 374)

Web service returning XML instead of JSON

I’m designing a web service (asmx) using the .NET framework 3.5 on an MVC site with the requirement to return JSON. Using some basic tutorials and the templates Visual Studio provides i was able to get a working model running on my laptop. When I deployed the solution to the server the results came back as XML.

I found the solution here. Since I am using .NET 3.5 for my web service, the handlers for the asmx  are not included in the machine.config. Adding the following line under system.webServer fixed this issue.

        &lt;add name="ScriptHandlerFactory"
             verb="*" path="*.asmx"
                 System.Web.Extensions, Version=, Culture=neutral, 
             resourceType="Unspecified" /&gt;

(Views: 297)

IE phone number lync icons

So my client wanted a footer on their home page with contact information which includes a phone number.  When I added the text for the number this weird icon appeared next to it to quick dial through Lync.

The format of the number was “+1.888.555.1234”. I searched for a solution online an besides disabling Lync phone icons from your browser, setting up custom rules on AD or  using jQuery (or even worse, CSS based on the GUID class name). I couldn’t find a best practice solution which would require minimal development effort and was not a serious hack.

What I ended doing to fix this issue was to break apart the number into two <span> tags so IE would not reorganize it as a number. The html looked like this:


While this is still kind of a hack (I foresee issues with giving span padding) this met the client’s requirements and seems like the most effective solution to the issue. If anyone has a better solution I’d love to hear it so please leave a comment below.

(Views: 288)

Slow download speed

I recently moved into a new house last week and was told the internet was “pretty good”. So it surprised me when I booted up my laptop and could not even load YouTube.

Not believing for one second that this was the “pretty good” internet i was told of, I went to “”. After running the full cycle of download/upload speeds i came up with a result of .26 Mbps and 11.2 Mbps. Now i was confused, upload is traditionally much slower than download. I opened my favorite browser and searched around until i found this post here.

Turns out the router has a settings called WMM. So what is a WMM? According to NetGear:

This technology maintains the priority of audio, video and voice applications in a Wi-Fi network so that other applications and traffic are less likely to slow them. In this way, in a phone conversation, you are less likely to hear delays. Watching video, you are more likely to see smooth action. This delays other network traffic of a less critical nature — such as downloading large files — where a small delay is acceptable.

So any Wi-Fi devices using a router with this enabled are going to have their download speeds drastically throttled. Switching this setting to “off” turned my .26 Mbps to 19.42 Mbps.

(Views: 563)