Category Archives: .Net

How to kill Sitecore – whilst installing an update package

Problem

Whilst installing an update package on the client’s/customer’s development environment the ASP.NET worker process would be killed suddenly. This issue was found on Sitecore 8.1 Update 4.

error

There was nothing shown in the Sitecore log or in the windows Event log. Therefore I took a Memory dump and investigated the dump using Debug Diagnostic 2 . I found at the bottom of the report 100000’s of lines with the same 4 lines of text, so I assumed there was an infinite loop, which was responsible for using all the memory, and crashing the ASP.NET worker process.

loop

I could not reproduce the error in a clean installation of Sitecore, so I assumed it was due to configuration and or some solution specific code. So I started making a comparison between the customers solution and the clean sitecore and I identified that the following settings where defined twice:

  • ServerTimeZone
  • ContentSearch.SearchMaxResults
  • ContentSearch.DefaultIndexConfigurationPath

showconfig.aspx confirmed this as you can see below.

1

2

The first was caused by an error in the solution specific configuration, the remaining were caused by 2 Sitecore includes having the same setting.

Solution

Ensure no settings and or other configuration is duplicate. Typically after I found out what the error was I discovered that Sitecore writes a warning in the log file! Maybe I should pay more attention to warnings.

warn

Anyway I hope this helps 🙂

 

 

 

 

Sitecore Commerce 8 powered by Microsoft Dynamics (SCpbMD) – Find the channel ID

Sitecore expects an integer value to identify the channel id, which is used to identify the online store to retrieve from the channel database.

The problem I faced was that the neither the Microsoft Ax Partner or the customer could give me the id, all they could find was the name which was a string value!

But fear not the following SQL statement which you can run against the channel database will show you all the channels and their assoicated id 🙂

SELECT TOP 1000 [NAME]
      ,[CHANNELID]
      ,[OPERATINGUNITNUMBER]
      ,[SERVER]
      ,[DATABASE]
      ,[ISPUBLISHED]
      ,[ISLOCAL]
      ,[CONNECTIONSTRING]
  FROM [AsyncClientDB].[crt].[STORAGELOOKUPVIEW]

Also ensure that channel is in fact published otherwise Sitecore can not use it, hope this helps Alan

channel id

How to filter AD roles or users using Sitecore’s LDAP module

Problem
Every time I have used AD for providing access to Sitecore, the active directory (AD) structure is crazy and recently I had a customer that had over 18000 roles, which made it difficult to assign roles and it killed the performance of the Sitecore client, as each user had at least 500 roles. Therefore Sitecore to evaluate the combination of a lot of roles to determine if they had read access or not.
18000I talked to the department responsible for the AD setup about changing and or creating a folder that only contained the Sitecore related roles, but this was not possible.

Initially I thought I would have to make own LDAP provider which derives from the standard provider, but I discovered this was not necessary as the LDAP module provides the functionality as standard.

Custom Filters
Custom Filter provide the ability to filter the roles and or users returned from the AD (see section 4.1 for full documentation).The custom filter uses the standard LDAP query syntax (see MSDN) to specify how the user or roles are filtered.

The following example ensures only roles, which contain Sitecore and or the special operations role; are imported into Sitecore. The Customcustom Filter

According to Sitecore documentation, both the User and Role provider must have the same CustomFilter, and that is why the (objectCategory=person) is added so all users are also imported regardless of their name.

I hope this blog post will help others using LDAP to control what roles or users are shown within sitecore.

Sitecore – RebuildSearchIndex|System.FormatException: Unrecognized Guid format.

After upgrading from 7.5.141003 to 7.5.150130, when I tried to rebuild the search index or the Link database I got the System.FormatException: Unrecognized Guid format after sometime!

Uli (@UliWeltersbach) had already written a great blog post about this exception and how to find the items causing the issue and how to fix the issue.

I would recommend you read Uli’s blog, but here is the quick version – The exception is caused by an error in the _tracking field used by the Analytic’s engine, which is very strange as the website has disabled the Analytic’s, see below?

disabled

Analytics is disabled, so why when I try to save the item to I get the following exception???

cant save

As I am not a very trusting person, I swapped to using raw values in the content editor and I could see that there was in fact data in the __tracking field!

raw

Cause

Initially the website did have analytics enabled I guess, but as some point it was disabled. The site was upgraded from 6.4 to 7.5 and somewhere along the line one or more of the update packages form sitecore did not update the __tracking field as analytics was disabled.

Therefore the old contents in the __tracking file were not in the correct format and caused the exception.

Solution

In my case deleting the contents was enough to fix the issue.

Another approach is to enable analytics edit the tracking field and save again, and it is converted to the correct format.

Sitecore – property change events flooding the Event Queue in the Core database

I had an issue that the EventQueue table in the Core database which was being flooded with events, which in turn was responsible for causing bad performance.

This was caused by the fact that each time the Lucene indexes are updated Sitecore raises the database:propertychanged event.

event queue core datbase

 

The default implementation subscribes to the event and adds it to the EventQueue table in the core database. I set the “Days To Keep” events to 1 day – but it still inserts over 100000 events a day 😦

Sitecore have registered this as a bug, but as yet there is no fix for 7.5 or 8.

Solution

This is not very nice at all, but  it was the best we could do as a workaround for this issue. The credit for this solution must go to my colleague Peter Wind (@peterwind) who is created the hack!

Use reflector to get the code for the default Sitecore.Eventing.Remote.RemoteEventMap class (defined in Sitecore.Kernel.dll), and create your own class, see below.

own class

Modify the SetupGlobalEventSubscribers function, so you subscribe to the database:propertychanged event – but do not add the event to the EventQueue, see below.

code change

The last step is to update the configuration in the web.config to use your new and improved class.

config

note: I have the support case number in the namespace & DLL name – so when the bug is fixed, I can remove this code and in addition any other developer at Pentia can see the history related to this support issue and why I have done such a nasty fix.

Anyway I hope this helps somebody out there 🙂

 

Sitecore SPEAK Insert Link Dialog – missing icons & sitecore tree – Don’t panic, U didn’t break it!!!!

I was upgrading a solution from 6.2 to 7.2 and it had a number of custom fields that no longer worked,  so I started to fix the code.

One of the custom fields showed the SPEAK  Insert link dialog and after making a lot of changes, I noticed that I had broken the SPEAK dialog, see below

Speak dialog....

I reviewed the changes I had made, and could not see what could have caused this issue? But to be on the safe side, I undid all of my changes, did a full build, etc and still I had the issue 😦

So I tried to open the dialog from a sitecore standard field, and it was also broken 😦

Solution

Whist starting to panic, after 5 minutes I noticed that the dialog had fixed itself!!!!

It appears that after a restart of the website the first time you open the “Insert link” dialog you have to wait 5 minutes for it to start working, after that it works straight away.

 

 

 

C# Regions

Whilst reviewing a solution I came across the class in the image below, and felt the need for a rant about using regions.

Regions C#

If you need regions, you should consider if the class has more than one RESPONSIBILITY and or is too big! In this case it is responsible for everything and over 1800 lines of code:-(

So a tip, if you need to use the #REGION’s in your code. I would advise you take a few moments and ensure that the class does not have mixed responsibilities. If it does have more than one responsibility you should split it up into a number of smaller classes with a clearly defined responsibility.

I re-factored the class into the following classes:

  • 4 Service classes
  • 13 Factories
  • 13 Repositories
  • 13 Model classes.

In fact by the time I had removed all the code from the class I found that it was not required at all 🙂