Skip to main content

.NET

Spawning Processes into Interactive Sessions

Starting a Windows process using .NET is normally an easy thing.You call Process.Start() with a l...

NET Core CORS Setup

Here’s a quick rundown on how to setup CORS in a NET Core API. It takes three pieces: CORS ...

Net Deep Copy/Cloning

Below are some references for different methods of accomplishing deep copies of object types. NO...

C# Equality Operator Overloading

Here’s a good example for how to implement operator for equality (==, !=, .Equals()). This is ta...

When Two Referenced Assemblies Have Overlapping Namespace

You will come across a problem at some point, where you will use a class, that exists in two libr...

DotNet Assembly Searching

Here are notes about the Assembly Helper classes that are part of OGA.SharedKernel.Lib and OGA.Co...

C# CLIWrap Chaining Multiple Statements

Normally, each call to CLIWrap is performed inside an independent terminal session. So, there mu...

C# Calculate Hash of List<T>

Here's a quick method that will generate a hash from a List of objects: public int GetHashCodeOf...

C# Check Two Lists<T> Are Equal

Quick method for check if two given lists of objects are equal: static public bool AreListsEqual...

Named Async Locks

As application complexity grows, you will eventually need a scalable way to serialize queries and...

Good Article on Net Core With or Without IIS

Publishing and Running ASP.NET Core Applications with IIS - Rick Strahl's Web Log (west-wind.com)

NET Core Func Variables

Here are some use cases for a Func. Func as Method Callback If you want to have a lambda that y...

C# Unit Tests with Async Task Signature

When writing unit tests, it’s good to standardize as much as possible.This includes the method si...

Process Logging Behavior

Here’s my current conventions for logging in application processes. Logging features, here are i...

Dotnet Dev on Linux

To create a new project at the current folder: dotnet new console --framework net6.0 --use-progr...

NET Core Error Responses

Here’s a decent mechanism for returning useful errors from a WEB API. Aside: We have a standing ...

NET Core Test API

We have a standing REST API with various endpoints for simulating different method types, return ...

Six Ways to Multi-Thread

Six ways to initiate tasks on another thread in .NET

Return Multiple Values from Async Method

Async method cannot have Ref or an Out parameters. So, we cannot pass back data from them through...

Strongly Typed Constant Parameters

You will eventually run into the need for a function to accept a restricted set of value for a pa...

Consuming Services Inside Startup

During Startup.ConfigureServices During application startup, the Startup.ConfigureServices metho...

NET Core Background Services

NOTE: Refer to this page for how to register and consume a background service: Consuming NET Core...

Consuming NET Core Background Service with DI

To properly consumes a background service from a controller or another service, it must be regist...

C# Disposed in Derived Types

People make lots of references to Microsoft articles about how to properly handle Dispose in deri...

Duplicating .NET Core DI

NOTE: If you are looking for how to access DI services, see this: HowTo Access DI Services Here ...

Unit Testing with IServiceProvider

When you create unit tests for class types that directly use DI to retrieve dependencies, you wil...

Unit Testing Conventions

Suppress Async Warning Project-Wide Since we have several calls to base classes for diagnostics ...

VS IDE Suppress Compiler Warnings Project Wide

There are some cases where it is necessary to suppress IDE compiler warnings that apply to the en...

#nullable Warning

If the compiler is giving you warnings about nullable reference types, then you may need to enabl...

.NET Framework Unit Testing Issues

Since we have some libraries that still output to NET Framework targets, some workarounds are req...

Unit Testing for an Exception

Sometimes, a unit test needs to ensure a particular exception type occurs. Here’s how to check t...

Unit Test Cheat Sheet

Here’s a list of elements for unit testing in Visual Studio using MSTest. Documentation for Visu...

C# Unit Test Template Classes

If you are using MSTest as your testing framework, and want to leverage the test functionality fr...

Xamarin

PostgreSQL DotNet DataType Mapping

Here’s a list of .NET datatypes, and how best to store each one. .NET Datatype Post...

Missing AspNetCore Nuget Packages

There are several aspects of an ASP Net Core web API that cannot be placed in a class library wit...

Ubuntu: How to Kill DotNet Runtime

Sometimes, a a dotnet runtime closes without releasing a listening port. This will prevent it fr...

HowTo Run DotNet Core App as Standalone

How to startup a net core application and specify the listening IP address and port: exename.exe...

Cancellation Token as Method Parameter

When writing a method that accepts a cancellation token, the method will need to deal with a pass...

.NET Process Boilerplate

Exploring standardized boilerplate for a variety of process types. Here's a known list of proces...

Updating Controls from Non-GUI Thread

Here are a couple methods for how to update form controls from a non-GUI thread. Explicit Setter...