Enum addition vs subtraction and casting

Good question – I was surprised that the first and third lines worked. However, they are supported in the C# language specification – in section 7.8.4, it talks about enumeration addition: Every enumeration type implicitly provides the following pre-defined operators, where E is the enum type and U is the underlying type of E: E … Read more

Getting list of currently active managed threads in .NET?

If you’re willing to replace your application’s Thread creations with another wrapper class, said wrapper class can track the active and inactive Threads for you. Here’s a minimal workable shell of such a wrapper: namespace ThreadTracker { using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading; public class TrackedThread { private static readonly IList<Thread> threadList = new List<Thread>(); … Read more

.NET functions disassembled

This prologue has two parts. Setting up the stackframe This stores the current EBP register on the stack and then assigns the value of the stackpointer(ESP) to EBP. push ebp mov ebp,esp If there are local variables that are stored on the stack (i.e. not enough space in the registers available) then ESP will be … Read more

.NET WebSockets forcibly closed despite keep-alive and activity on the connection

I ran into this issue this week. Your workaround got me pointed in the right direction, but I believe I’ve narrowed down the root cause. If a “Content-Length: 0” header is included in the “101 Switching Protocols” response from a WebSocket server, WebSocketClient gets confused and schedules the connection for cleanup in 100 seconds. Here’s … Read more

What .NET-compatible graph database solution(s) have a proven track record?

Trying to implement a graph database in Mongo is a rabbit hole that’s been tried before. See this message from the TinkerPop user group: https://groups.google.com/d/msg/gremlin-users/_zweYGxR8wM/0AUu-UoqTRIJ Microsoft’s Trinity graph is an internal project not available for download: http://research.microsoft.com/en-us/projects/trinity/ Neo4j Server (http://neo4j.org) paired with Romiko and Tatham’s .NET client (http://hg.readify.net/neo4jclient/wiki/Home) is a popular combination. Neo4j scales to … Read more

How to export PDF page as an image using PDFsharp .NET library?

The answer can be found in the PDFsharp FAQ list: http://www.pdfsharp.net/wiki/PDFsharpFAQ.ashx#Can_PDFsharp_show_PDF_files_Print_PDF_files_Create_images_from_PDF_files_3 PDFsharp creates PDF files, but it cannot render them. The call Bitmap b = new Bitmap((int) pdfp.Width.Point, (int) pdfp.Height.Point, xgfx.Graphics); does not initialize any bits of the bitmap and does not copy anything from the Graphics object except for the DPI setting of the … Read more

Workaround for WPF Freezable bug?

To workaround this .net bug, change all of the Solid Color Brushes in your code to be freezeable. For example <SolidColorBrush x:Key=”WindowBackground” Color=”Black” /> should be changed to: <SolidColorBrush po:Freeze=”True” x:Key=”WindowBackground” Color=”Black” />. For more detailed instructions see here: How can WPF objects deriving from Freezable be frozen in XAML?.

How do I actually create a .NET Core project in Visual Studio?

.NET Core templates are available in Visual Studio 2017. When installing VS2017, you have to pick the “.NET Core cross-platform development” workload. Once you do, you’ll have access to the templates: Click File – New Project. Expand Visual C# – .NET Core on the left side. Pick one of the templates. If you’re on Visual … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)