Sitecore Swamp

Dive in the Sitecore Swamp

NAVIGATION - SEARCH

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.1.0

12.0.0-r00549

12.0.0.0

9.0 Update-2 rev.180604

9.0.180604

11.1.2-r00461

11.1.2.461

9.0 Update-1 rev.171219

9.0.171219

11.1.1-r00395

11.1.1.395

9.0 Initial Release rev.171002

9.0.171002

11.1.0-r00369

11.1.0.369

8.2 Update-7 rev.180406

8.2.180406

10.0.9-r00605-3092e47

10.0.9.605

8.2 Update-6 rev.171121

8.2.171121

10.0.8-r00560-a977d2d

10.0.8.560

8.2 Update-5 rev.170728

8.2.170728

10.0.7-r00479-015e736

10.0.7.479

8.2 Update-4 rev.170614

8.2.170614

10.0.6.-r00427-7aa1a4e

10.0.6.427

8.2 Update-3 rev.170407

8.2.170407

10.0.5-r00377-d79211d

10.0.5.377

8.2 Update-2 rev.161221

8.2.161221

10.0.4-r00315-8752614

10.0.4.315

8.2 Update-1 rev.161115

8.2.161115

10.0.3-rev.r00309-1d4ac49

10.0.3.309

8.2 Initial Release rev.160729

8.2.160729

10.0.0 rev.160279

10.0.0.5597

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 http://www.rockpapersitecore.com/2017/10/sitecore-rocks-with-sitecore-9/. 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">
  <system.web>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
  </system.web>
</location>

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.

 

https://marketplace.visualstudio.com/items?itemName=MikeWard-AnnArbor.VSColorOutput

 

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

Issue

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.

Investigation

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.

Resolution

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?

Issue:

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:

Investigation:

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:

<sites>

...

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

...

Resolution:

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

Issue:

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: 

Investigation:

As read https://jira.mongodb.org/browse/SERVER-19086, some OpenSSL DLL files are missing from MongoDB 2.6.4 download, and it causes the problem to install on Windows 10. 

Resolution:

You can either download OpenSSL and find the missing DDL files there as suggested in the article. I just have it upload here

mongo-install-missing-openssl-libs.zip (944.23 kb) (SHA1: 050967C31CE3B728038003814F43883BC2108E68)

Cheers!

Frequently used Regex

^(.*)(\r?\n\1)+

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

 

\(.*

find string which start with (

 

((\bScript\b)|(\bJavascript\b)) 

find lines which has either Script or Javascript