Sitecore Swamp

Dive in the Sitecore Swamp


Update ShardsGlobal for xDB migration (Sitecore 9+)

In Sitecore 9+, xDB data can be stored in SQL databases. To ensure the performance, Sitecore uses Shard databases, see Jason article Sitecore 9 xDB Sharding. The sharding data is managed in ShardMapManager table, which stores the server name and database. It works like a charm, but just one issue. The server name and database is hard references, which can cause problems for data migration. If you are trying to create a Sitecore instance from database dumps, the DatabaseName and ServerName need to be updated in [Xdb.Collection.ShardMapManager].[__ShardManagement].[ShardsGlobal]


Sitecore Version from Sitecore.Kernel.dll (8.2.* - 9.*)

Sitecore Version

NuGet Version

Kernel Product Version

Kernel File Version

9.1 Initial Release



9.0 Update-2 rev.180604



9.0 Update-1 rev.171219



9.0 Initial Release rev.171002



8.2 Update-7 rev.180406



8.2 Update-6 rev.171121



8.2 Update-5 rev.170728



8.2 Update-4 rev.170614



8.2 Update-3 rev.170407



8.2 Update-2 rev.161221



8.2 Update-1 rev.161115



8.2 Initial Release rev.160729


10.0.0 rev.160279

Sitecore Rocks connection error in Sitecore 9

Installed a fresh new Sitecore 9 environment, and trying to connection Sitecore via Sitecore Rocks. But, surprisingly, hit a connection error:

Checked the following permission things:

  • The app pool identity has permission to website folder
  • Visual Studio is running under Administrator

No resolved, until I found this article Due to some security changes with Sitecore 9, Rocks will have a problem connecting to the instance. The solution is quite simple, just add the following config to web.config:

<location path="sitecore/admin">
      <deny users="?" />
      <allow users="*" />

Now it works!

Visual Studio Extension - VSColorOutput

If you like me, always turn on the detailed build output verbosity, you must know the output information is bit too much. Now with VSColorOutput, it becomes quite easy to focus on the more important things.

What is it?

VSColorOutput can change the color of a line emitted to the output window based on specified rules. The rules consist of regular expressions. Rules map to classifications which in turn map to colors. (More information)

The default patterns will color build errors in red, warnings in yellow/gold and successfull build messages in green.


Could not load file or assembly 'ChilkatDotNet45.dll' or 'ChilkatDotNet46.dll'?


In a recent job, I need to spin up a vm box and install Sitecore 8.1.3 environment with existing deployed code. When everything is done, start the website, an error displays: 

Server Error in '/' Application.

Could not load file or assembly 'ChilkatDotNet45.DLL' or one of its dependencies. The specified module could not be found.


It turns out that EXM has dependencies on the Chilkat dot assembly, and it requires Visual C++ 2012 (x64) rumtime. As the version is so old, it's not installed.


Download and install Visual C++ 2012 Redistributable (x64) fixes the issue. With Sitecore 9, it would be Visual C++ 2015 Redistributable (x64) 



My Toolbox - 2018

As working as a consultant, often to spin up a new development environment. Besides the VS and SQL, there are plenty of useful tools/extensions need be installed as well. Here's a list of the tools which I can't live in my coding life without:

-. Notepad++
-. 7zip
-. Resharper (dotPeek and dotTrace), undoubtable the No 1.
-. Test Driven, right click and run any method
-. CodeCompare, after years of WinMerge, this one has became my favorite code compare tool, and sorry 
-. Winmerge, still have a place here as the folder comparison is a thumb-up.
-. Wireshark, never disappoint you if you know how to talk to it (query and filter)
-. Postman is new here, as it's easy play with services
-. Fiddler, Chrome has replaced most of uses Fiddler
-. Ditto, ctrl+~ prompt the list of clipboard history, simple and useful (thanks to Ke and Bruno)
-  TOC

Sitecore Virtual User - Can't Save Profile Property

It's quite common to create some custom properties and save them for virtual users. I just encountered a problem that the profile properties are not saved, even specifically calling virtualUser.Profile.Save().

After a couple hours code debugging and dot peeking, found the cause of the problem: 

The custom profile properties are saved into Core db - ClientData table (since Sitecore 8.1.1). The identifier is the session key. In Sitecore code, it's using WebUtil.GetSessionID() to generate the key. Here is the peeked code:

    public static string GetSessionID()
      HttpContext current = HttpContext.Current;
      if (current != null && current.Session != null)
        if (current.Session.IsNewSession && Settings.Performance.ForceASPSessionIDPersist)
          current.Session["__forceSessionPersist"] = (object) "dummy";
        return current.Session.SessionID;
      string sessionIdCookieName = WebUtil.GetSessionIdCookieName();
      Assert.IsNotNull((object) sessionIdCookieName, "key");
      if (!Context.IsUnitTesting)
        return WebUtil.GetCookieValue(sessionIdCookieName);
      return WebUtil.GetCookieValue(sessionIdCookieName, "unittests.net_sessionid");

If this is the initial request, the session can be null, and, of course, there no session cookie either. In this case, WebUtil.GetSession() returns empty string, which causes nothing can be persisted into database.

Why can't I login with Admin?


It's quite common scenario for a Sitecore consultant to spin up a environment from existing implementation. After you reset password for the Admin user, you still have the error prompt on your face:


And you checked in the database, the user ("B09BBCDE-9B3C-4DCD-B69E-67F615CE01E9") is not locked or not approved. Then there's another place can explain this:



<site name="login" virtualFolder="/sitecore/login" physicalFolder="/sitecore/login" enableAnalytics="false" database="core" domain="custom" disableXmlControls="true" />



The default domain has been changed, and you have to login with sitecore\admin rather than admin, or change domain back to sitecore.


Missing OpenSSL lib DLLs when installing MongoDB 2.6.4


For my work, I have to deal a lot of older Sitecore versions. In Sitecore 803, it needs MongoDB 2.6 according to the compatibility table. When I install MongoDB 2.6.4, an error popup: 


As read, some OpenSSL DLL files are missing from MongoDB 2.6.4 download, and it causes the problem to install on Windows 10. 


You can either download OpenSSL and find the missing DDL files there as suggested in the article. I just have it upload here (944.23 kb) (SHA1: 050967C31CE3B728038003814F43883BC2108E68)


Frequently used Regex


find duplicated lines in text, to replace with only one instance use \1



find string which start with (



find lines which has either Script or Javascript


find the characters which contains only 0-9, T, :, ., or Z, for length of 28