• About
  • Privacy Policy
  • Utilities
Darchuk.NET

.NET

Creating a .zip file with .NET

July 5, 2019 by Robert Leave a Comment

For some reason I always thought that you needed to add a third party library to make a zip file in C#, but apparently you can do it easily with an API that already exists in the framework. via GIPHY ZipArchive All you need to do is create a file and associate the file stream … [Read more…]

Posted in: .NET Core, C# Tagged: .NET, C#, DotNet, Zip

Spoofing a C# Stopwatch

May 24, 2019 by Robert Leave a Comment

C# has a Stopwatch class that is pretty accurate at timing things.  In fact, it uses some low-level operating system stuff to make sure to get exact timings.  This means it can be more accurate than comparing two different DateTime.Now instances. via GIPHY I’ve found myself using the Stopwatch occasionally, but it always is kind … [Read more…]

Posted in: .NET Core, C#, Unit Testing Tagged: .NET, C#, Testing, unit testing

Autofac–Automatically registering generics via constructors

May 17, 2019 by Robert Leave a Comment

Recently I had a situation where I had a class and interface to make a generic service which would do something based on whatever type is provided.  (Obviously, it was not so contrived…) These would then get injected to other classes to be used as necessary: Which works fine… as long as you remember to … [Read more…]

Posted in: .NET Core, C#, Reflection Tagged: .NET, AutoFac, C#, Csharp, DependencyInjection, Generics, IoC, Reflection

Extending Autofac Modules

May 10, 2019 by Robert 1 Comment

Autofac is a popular dependency injection library that I like to use because they’ve done a lot of legwork to get things to work nicely in .NET Core – (some DI frameworks were not happy with Microsoft’s decision to make a public abstraction for their own DI library). Modules If you have a big solution … [Read more…]

Posted in: .NET Core, C# Tagged: .NET, AutoFac, C#, DependencyInjection, DI

.NET Core WebApp–Set Port on Command Line Launch

February 22, 2019 by Robert Leave a Comment

There are a bunch of different ways to do this, but sometimes I find myself wanting to run multiple web applications locally on different ports without fussing with configuration files, etc.  And whenever I need to do this, I always have to look it up… but most of the posts out there are how to … [Read more…]

Posted in: .NET Core, ASP.NET, Web Development Tagged: .NET, .NET Core, ASP.NET, C#, WebAPI

Thread-Safe Atomic Operations

June 29, 2018 by Robert Leave a Comment

There’s been more than a couple times where I’ve wanted to use the Parallel class to take a collection and rip through it with multiple threads, but I’ve struggled with how to log the progress (especially the count of objects processed) easily. Interlocked .NET actually provides the solution in a static class called Interlocked, located … [Read more…]

Posted in: .NET Core, ASP.NET, Asynchronous, C#, Concurrency Tagged: .NET, C#, Concurrency, Thread, Thread Safe, threading

C# Reflection with Generics

June 22, 2018 by Robert 1 Comment

If you find yourself writing a lot of the same code (or copy/pasting it) for similar constructs, you should probably consider using generics.  It allows you to write a base class full of functionality that is basically the same across all of different classes, but in a way that doesn’t tie you to a specific … [Read more…]

Posted in: .NET Core, C#, Generic, Reflection Tagged: .NET, C#, Constructor, Generics, Parameter, Reflection, Template, Type

C# Mapping an Enum to a key value pair

May 18, 2018 by Robert 2 Comments

Enums are useful because they help you avoid magic numbers.  You can write your code in a way that is easy to read and understand from the human’s perspective, which, at the end of the day, is pretty important. Exposing enums on your Web API I want to share my enums with other things, notably … [Read more…]

Posted in: .NET Core, ASP.NET, C#, Typescript, Web API, Web Development Tagged: .NET, Angular, ASP.NET, C#, enum, Typescript, Web API

Capturing and Analyzing localhost to localhost traffic on Windows

March 30, 2018 by Robert Leave a Comment

Recently I had an issue where I was trying to create a stubbed/mocked version of a SOAP service locally.  I ran my web application, my client connected, my service got the request, sent back the response and… the client didn’t like it.  Not sure why… everything should be working.  So I wanted to look at … [Read more…]

Posted in: .NET Core, C#, Web Development Tagged: .NET, C#, capture, localhost, Packet, SOAP, TCP, Wireshark

ASP.NET Core [FromBody] Null?

February 16, 2018 by Robert Leave a Comment

Recently I was having an issue where a parameter being passed in to my WebAPI call was not being populated correctly. Theoretically all you need to do is add [FromBody] to the route, and it will automatically populate the object from the HTTP message’s body… but that wasn’t working for me Turns out this IS … [Read more…]

Posted in: .NET Core, C#, Web API, Web Development Tagged: .NET, .NET Core, [FromBody], model, Null, Serialization, Web API

Recent Posts

  • Allowing trailing JSON commas in ASP.NET Core 3
  • YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
  • Logging in a .NET Core 3 SignalR client
  • .NET Core 3 unit testing project sdk
  • .NET Core 3.0 Upgrade–New JSON Serializer Gotchas

Recent Comments

  1. Robert on C# Setting Socket Keep-Alive
  2. Oliver Schramm on C# Setting Socket Keep-Alive
  3. John Anderson on Waiting for a keypress asynchronously in a C# console app
  4. Ronald Garlit on .NET Core 3 unit testing project sdk
  5. Ronald Garlit on .NET Core 3 unit testing project sdk

Copyright © 2025 Darchuk.NET.

Omega WordPress Theme by ThemeHall