Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

58 total results found

Consuming NET Core Background Service with DI

.NET

To properly consumes a background service from a controller or another service, it must be registered with DI. As well, since it’s a background service… it must be running… and probably a singleton. NOTE: If you are looking for how to generate an instance of...

.net
service
dotnet
programming

Duplicating .NET Core DI

.NET

NOTE: If you are looking for how to access DI services, see this: HowTo Access DI Services Here are the steps to duplicating the .NET Dependency Injection process, to create a ServiceProvider instance. This is especially useful in unit testing, for classes an...

IServiceProvider
unittests
testing
DI
.net
dotnet
programming

Unit Testing with IServiceProvider

.NET

When you create unit tests for class types that directly use DI to retrieve dependencies, you will need a way to give them a reference to a service provider (IServiceProvider). This is transparently done by the runtime.But, we have to mimic it for unit testin...

programming
dotnet
DI
unittests
testing
.net

VS IDE Suppress Compiler Warnings Project Wide

.NET

There are some cases where it is necessary to suppress IDE compiler warnings that apply to the entire project. This can be warnings that occur several times across the source files. Or, it can be for a compiler warning that the project’s framework target is ...

programming
.net
dotnet

#nullable Warning

.NET

If the compiler is giving you warnings about nullable reference types, then you may need to enable nullables in the csproj file. This can happen when you declare a public class property, like this: public TaskConfigBase? ConfigBase { get; set; } Sin...

.net
dotnet
programming

NET Core Test API

.NET

We have a standing REST API with various endpoints for simulating different method types, return errors, and such. It’s Swagger page is, here: http://192.168.1.201:4250/swagger/index.html

testing
infrastructure
programming
dotnet
.net

Unit Testing for an Exception

.NET

Sometimes, a unit test needs to ensure a particular exception type occurs. Here’s how to check that a particular exception and message occurs. The catch is that, when executing code inside a unit test framework, such as MSUnit, any exception thrown by code i...

dotnet
.net
programming
unittests
testing

C# Unit Tests with Async Task Signature

.NET

When writing unit tests, it’s good to standardize as much as possible.This includes the method signature for each test cases, such as this: // Test_1_1_1 Describe the test... [TestMethod] public async Task Test_1_1_1() { // Do some testing... ... ...

unittests
dotnet
.net
programming
testing

Unit Test Cheat Sheet

.NET

Here’s a list of elements for unit testing in Visual Studio using MSTest. Documentation for Visual Studio Testing is here: GitHub - microsoft/vstest-docs: Documentation for the Visual Studio Test Platform. Necessary Packages The following packages are neces...

unittests
testing
dotnet
.net
programming

C# Unit Test Template Classes

.NET

If you are using MSTest as your testing framework, and want to leverage the test functionality from OGA.Testing.Lib, here are the minimal classes and structure you will need. For a cheat-sheet on MSTest framework usage, see this: Unit Test Cheat Sheet Depend...

testing
unittests
dotnet
.net
programming

.NET Framework Unit Testing Issues

.NET

Since we have some libraries that still output to NET Framework targets, some workarounds are required because of some design choices that have been made in the MSTest library and Test Explorer. MSTest Project Styles (SDK vs Non-SDK) NOTE: This only applies ...

testing
programming
.net
dotnet
unittests

.NET iOS Runtime Limitations

.NET Xamarin

Here’s some notes on the limitations imposed by IOS for Xamarin and MAUI applications. These apply to both Xamarin and MAUI apps written for iOS. Basically, the iOS kernel prevents any application from generating dynamic code at runtime. So, any usage of JI...

.net
Xamarin
dotnet
programming

PostgreSQL DotNet DataType Mapping

.NET

Here’s a list of .NET datatypes, and how best to store each one. .NET Datatype PostGreSQL DataType datetime (UTC) timestamp without time zone Guid uuid float real double double precision ...

database
postgres
programming
.net
dotnet

PostgreSQL Bulk Insert

PostgreSQL

Here’s a means to insert multiple records in a single insert call, which is about 40 times faster than performing an explicit insert for each row. We will leverage the BeginBinaryImport method on the database connection class of the NPGSQL library. To make t...

programming
.net
dotnet
database
postgres

Missing AspNetCore Nuget Packages

.NET

There are several aspects of an ASP Net Core web API that cannot be placed in a class library without a little extra care. This is because Microsoft decided to remove “many of the core assemblies” from nuget packages for the ASPNetCore, when Net Core 3.0 was p...

nuget
dotnet
programming
.net

Ubuntu: How to Kill DotNet Runtime

.NET

Sometimes, a a dotnet runtime closes without releasing a listening port. This will prevent it from restarting, because the port is already in use.   While running the dotnet run if you stop the server using ctr + z then it Ctrl+z sends the SIGTSTP (Signal T...

.net
dotnet
Administration

HowTo Run DotNet Core App as Standalone

.NET

How to startup a net core application and specify the listening IP address and port: exename.exe run --urls "http://192.168.1.110:6000"

.net
dotnet
deployment

VS Project Conditional Constants

.NET

When developing cross-platform libraries, you will have the need to enable and disable different parts of your source code based on what statements or functions work on each platform. For example: Processes are queried differently in Windows than linux.And, c...

.net
programming
dotnet

.NET Core In-Memory Cache

.NET

Here is a working method for using the In-Memory cache. For a thread-safe cache update, see the example at the bottom. Assimilate this into a working project: In-Memory Caching in ASP.NET Core - Code Maze Understanding & Implementing Caching in ASP.NET C...

programming
dotnet
.net

How To Add Release Notes to Nuget Package

.NET

These are the steps needed to include release notes in a Nuget package. These are taken from this article:Writing a NuGet package release notes in an outside of a .csproj file. Same article here:Writing a NuGet package release notes in an outside of a .csproj...

nuget
programming
dotnet
.net