Sitecore Swamp

Dive in the Sitecore Swamp

NAVIGATION - SEARCH

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

Sitecore MVP nomination ends today!

Want to become Sitecore MVP? Want to go Las Vegas for next year's MVP Summit? Do it now, or have to wait for another year.

You need the nomination and recommendation, and it's closing today! Go to http://www.sitecore.net/mvpnomination. If not already a Sitecore MVP, you also need a Sitecore employee or MVP to recommend you to qualify the nomination. 

I am going to re-nominate for Sitecore MVP 2017, wish me luck! 

Object Exporter - Visual Studio Extension

Has it happened to you that you want see and save a variable value when you doing debug in visual studio. For example, for a particular exception, you want save and share the detailed information, or you have a list of objects too difficult to watch. You can type the variable in immediate command window, and copy/paste the output, or you can use Object Exporter.

Start your debug mode, and make a break point. Now highlight the variable, and tools > Export Objects:


You can choose output format as C# Object Initialization Code, JSON and XML. Pretty cool!