Author Archives: briancaos

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.

C# Azure TelemetryClient will leak memory if not implemented as a singleton

I noticed that my classic .net web application would leak memory after I implemented metrics for some background tasks. Further investigation showed that my MetricAggregationManager would not release its memory. Since one of the major changes was the implementation of … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , | Leave a comment

Sitecore Memory Issues – Every memory optimization trick in the book

My recent post, Sitecore high memory usage – not always a problem, claims that high memory usage is not the same as having a memory problem in Sitecore. But the reason you are reading this blog is because the memory … Continue reading

Posted in Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , , , , , | Leave a comment

Sitecore high memory usage – not always a problem

Sitecore is known to be a real memory hog. Especially the CM server is known to love memory. One of the memory issues that Sitecore faces is the high usage of the Large Object Heap. WHY IS THIS A PROBLEM? … Continue reading

Posted in Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , , , , , | 1 Comment

Remove duplicates from XML feed

Apparently XML isn’t dead yet, and today I received a Google Product Feed in the RSS 2.0 XML format. The feed was full of duplicates and my job is to remove them: As you can see, “Product 100” appears twice. … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , | Leave a comment

HttpClient retry mechanism with .NET Core, Polly and IHttpClientFactory

A lot of HttpClient errors are temporary and is caused by server overload, temporary nerwork timeouts and generic gliches in the Matrix. These scenarios can be dealt with using a retry pattern. In .NET Core, the most common retry library … Continue reading

Posted in .NET Core, General .NET | Tagged , , | Leave a comment

.NET Core Worker Services with Application Insights and Serilog

The .NET Core Worker service is yet another tool in the .NET toolbox. They are perfect for background processing like reading from a queue or making health checks. They are cross-platform (of course) and they can run on docker containers, … Continue reading

Posted in .net, .NET Core, c# | Tagged , , , | 4 Comments

System.DllNotFoundException: Unable to load DLL ‘sni.dll’ or one of its dependencies: The specified module could n ot be found. (0x8007007E)

This message happens when deploying my .NET Core 3.1 application to production (when compiling the code to an .exe file), but not when running the application locally. It turns out, that Dapper is missing a reference to System.Data.SqlClient. Adding the … Continue reading

Posted in .net, .NET Core, c# | Tagged , , | 1 Comment

Sync Sitecore content to external database

The legal department of the client requested that we sync parts of the Sitecore tree to an external, system-versioned temporal table, so that we have a full audit trail of changes to these items including before-and-after values. Fear not, this … Continue reading

Posted in .net, c#, Sitecore 5, Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , , , , , , | Leave a comment

C# Get expiry timestamp from JWT token

JWT tokens (or Json Web Tokens) are an open-standard the defines a way to transmit information between 2 parties in a secure manner. Identity Server 4 uses JWT as a security token. These tokens have an expiry timestamp, and if … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , , | Leave a comment

Application Insights not working in .NET Core Console Application – Remember to flush the TelemetryClient

My .NET Core console application did not write to my Application Insights instance. Well, it did, but only sometimes. Writing to Application Insights is done asynchronously, usually every 30 seconds or 500 items. This means that you need to give … Continue reading

Posted in .NET Core, Microsoft Azure | Tagged , , | Leave a comment