Articles Tagged “C#”
76 articles tagged “C#”, newest first.
-
Why Arguments Break — The Rules of Windows Command-Line Arguments
Windows passes CreateProcess a single string that the receiver splits. Covers the CommandLineToArgvW, CRT, and .NET rules, ArgumentList, and building it in C++.
-
End of Servicing for Windows Printer Drivers — How Business Apps Should Prepare Their Report and Label Printing
Microsoft is phasing out v3/v4 printer drivers. What Windows protected print mode removes, and how to inventory and prepare report and label printing in busi...
-
What Is Left After the Parent Dies — Keeping Child Processes in a Job Object
Why do SDK helpers outlive a killed UI and keep the camera or COM port? Designing child process lifetime with Job Objects, KillOnJobClose, and completion ports.
-
Named Pipes in Practice — Windows' Standard IPC from Design to Security
A practical guide to named pipes, Windows' standard IPC. Covers byte vs. message mode, servers that handle multiple clients, ACL and impersonation security, ...
-
Spurious Wakeups — Why a Condition Variable Wakes "Without a Notification" and How to Wait Correctly on Windows
Condition variable waits can wake with no notification (spurious wakeups). Why Windows allows it, and the correct while-and-predicate wait in Win32, C++, and...
-
Practical Multithreading Best Practices: .NET Edition — What to Decide Before You Add More Threads
Keep .NET/C# threads from crashing or hanging. Ride on Task, cut shared mutable state, lock with discipline, stop with CancellationToken, and respect the UI ...
-
Using WMI/CIM from C# and PowerShell — A Practical Guide to Hardware Inventory, Process Monitoring, and Remote Queries
WMI/CIM is the standard way to read a PC serial number, watch disk space, and detect process starts. Covers CIM cmdlets, Get-WmiObject migration, C# APIs, an...
-
The Depths of Windows I/O (Part 4) — Cache Manager: When Does Your WriteFile Actually Reach the Disk?
Part 4 of a diagram-led Windows Cache Manager series. It covers the cache as a file mapping, read-ahead, lazy writing, FlushFileBuffers, FILE_FLAG_NO_BUFFERI...
-
The Depths of Windows I/O (Part 3) — I/O Completion Ports (IOCP) and the .NET Thread Pool: The Basement Under async/await
Part 3 of a diagram-led series on I/O completion ports (IOCP). It covers the queue plus thread-count control, the concurrency value, LIFO release, and .NET c...
-
How Long Can You Go On Using MSMQ? — The Migration Decision for a Legacy Queue That Isn't Even "Deprecated"
MSMQ is not on Microsoft's deprecated lists, yet System.Messaging is .NET Framework-only and blocks .NET migration. How to decide whether to keep it, and wha...
-
The Depths of Windows I/O (Part 2) — Synchronous and Asynchronous I/O: What OVERLAPPED Really Means
Part 2 explains Windows synchronous and asynchronous (overlapped) I/O: FILE_FLAG_OVERLAPPED, the four notification paths, synchronous completion, cancellatio...
-
The Depths of Windows I/O (Part 1) — Every Read and Write Becomes an IRP: The Big Picture of the I/O System
Part 1 of a series on Windows I/O from the ground up: the Object Manager namespace, the driver, device and file objects, the IRP lifecycle, and what CloseHan...
-
What Is the TPM in Windows? — An Illustrated Guide to the "Safe That Never Lets Keys Out" and Measured Boot
An illustrated TPM guide. It covers keys that never leave the chip, PCRs and Measured Boot, BitLocker and Windows Hello, dTPM, fTPM and Pluton, Get-Tpm, and ...
-
Never Use a QR Code's Decoded Value As-Is — Error Correction Succeeding Does Not Guarantee the Value
QR error correction does not guarantee the decoded value. Sample images and two decoders show why dirt can yield a different value, and what a business syste...
-
How to Work with USB Devices from a Windows App — Choosing Between virtual COM, HID, WinUSB, and Vendor SDKs
A comparison of four ways to control equipment and USB devices from a Windows application: virtual COM port, HID, WinUSB, and vendor SDKs. We cover whether a...
-
How to Replace an exe or DLL That Is In Use — Restart Manager and the "File In Use" Problem in Auto-Update
Why can't an exe or DLL that is in use be replaced? This article covers the locking of running files and the fact that renaming is still allowed, enumerating...
-
Registry 32-bit/64-bit Redirection and Virtualization Pitfalls — Wow6432Node and the "The Value I Wrote Isn't There" Problem
How a 32-bit app's writes to HKLM\Software get redirected to Wow6432Node, the conditions under which UAC virtualization diverts them to the VirtualStore, the...
-
Code Design for Business Systems — Deciding Product and Customer Codes, and Check Digits
A practical guide to deciding the code scheme for a business system, including product and customer codes. Covers a decision table for meaningful codes versu...
-
DLL and COM Interface Backward Compatibility — A Decision Table for Which Changes Break Callers
Which changes to a DLL or COM component actually break their callers? We lay out the three layers of compatibility — binary, source, and behavioral — a decis...
-
Versioning Your Business App's Database Schema — Migration Practices to Prevent 'Every Customer Has a Different DB'
A practical guide to versioning the database schema of a business app whose databases are scattered across customer sites. Covers PRAGMA user_version and a C...
-
CI/CD for WinForms / WPF Apps in Practice — Automating from Build to Signing and Distribution with GitHub Actions
A practical guide to setting up CI/CD for WinForms / WPF apps with GitHub Actions. Covers a minimal YAML for build+test on windows-latest, tag-driven version...
-
Safely Modifying a Legacy Business App That Has No Tests — Characterization Testing and Refactoring in Practice
To safely modify a business application with no tests, this article explains, with C# examples, the procedure for a characterization test (the golden master ...
-
When Your In-House Windows App Gets Flagged as a Virus — Handling Microsoft Defender False Positives and Living With the Performance Impact
We lay out the proper way to respond when Microsoft Defender flags your in-house Windows app as malware: how modern antivirus detection actually works, how t...
-
Sleep, Hibernation, Modern Standby, and Long-Running Apps — Designing Around 'It Stopped Overnight'
Why a long-running Windows app can end up 'stopped by the time you check it in the morning,' worked through from the differences between S3 sleep, hibernatio...
-
Do Business Apps Run on Windows on Arm? — The Reality of x64 Emulation (Prism) and Native DLLs/COM
An answer, aimed at developers and IT staff, to 'will our business app run on Windows on Arm?' Covers how x64 emulation (Prism) works, the layers it can't re...
-
MAX_PATH and Windows Path/Filename Pitfalls — the 260-Character Limit, Reserved Names, Trailing Dots, and Case Sensitivity
A rundown of the path and filename limits behind the classic 'file not found' bug. Covers the breakdown of MAX_PATH=260, enabling long paths with LongPathsEn...
-
Pitfalls of Network Drives and UNC Paths — Working With File Servers (Shared Folders) From a Business Application
This article organizes the classic problems that show up when a business application writes to or watches a shared folder: why a drive letter (Z:) is invisib...
-
System Tray Icons and Toast Notifications in Windows Apps — NotifyIcon Pitfalls and Choosing the Right AppNotification API
A practical guide to keeping a business Windows app resident in the system tray and notifying users with toast notifications. Covers the correct use of Notif...
-
How Long Will VB6 Apps Keep Running? — Runtime Support Status and a Practical Path to .NET Migration
How long will VB6 applications keep running? This practical guide clarifies the asymmetry between the VB6 runtime support policy (still supported on Windows ...
-
Japanese Era Dates, Public Holidays, and Closing-Date Processing in Business Apps — Era-Resilient Design, JapaneseCalendar, and Business-Day Calculations in Practice
A report that must show '令和8年' in the Japanese era, business-day calculations that exclude public holidays, payment due on the last business day of the month...
-
Localizing WinForms/WPF Apps — resx, Satellite Assemblies, and Culture Switching in Practice
A practical guide to localizing Windows desktop apps, covering the difference between CurrentCulture and CurrentUICulture, how resx and satellite assemblies ...
-
CSV Is Not "Just Text": A Practical Guide to CSV Handling in C# Business Apps (Encoding, Excel Compatibility, Injection Defense)
A practical rundown of the classic failure patterns in business-app CSV I/O - hand-rolled Split(',') parsing, mojibake from BOM-less UTF-8 in Excel, lost lea...
-
Don't Wrap HttpClient in a using Block — Practical HTTP Communication in C# Business Apps (Creation Patterns, Timeouts, Retries)
Creating a new C# HttpClient with using on every request exhausts sockets, but making it static means it stops following DNS changes. This article walks thro...
-
Pinpointing "Slow" with PerfView and dotnet-trace — A Practical Introduction to .NET Performance Investigation
When a business app is "slow," "pegs the CPU," or "occasionally freezes," which tool should you reach for, and what should you look at? This article walks th...
-
An Introduction to Windows Event Log and ETW — Putting Your Business App's Logs on the OS's Standard Mechanisms
Are you relying on file logging alone for your Windows business app? Event Log and ETW are records visible on a different layer — to operations staff and OS-...
-
More Than appsettings.json — A Practical Guide to Configuration Management in Windows Business Apps (Per-Environment Settings, Secrets, and Where to Write)
A practical look at configuration management for Windows business apps: layering appsettings.json, choosing between IConfiguration and the IOptions/IOptionsS...
-
Printing and PDF Output in Windows Business Apps — Choosing Between System.Drawing.Printing, WPF, and Report Libraries
Organizes WinForms printing with PrintDocument, WPF FlowDocument/FixedDocument printing, and PDF output options into a requirement-based decision table. Cove...
-
Getting a Real Feel for the OSI Model — Dissecting a Single HTTP Request Into Its Seven Layers
Understand the OSI model through the real thing instead of rote memorization. We assemble and dissect, in C#, the Ethernet frame carrying a single HTTP GET r...
-
How to Think About Windows Session Isolation — Session 0, RDP, and Running Multiple Users Concurrently
This article untangles the concept of a Windows "session," a topic that consistently confuses Windows app developers. It covers why Session 0 isolation exist...
-
Reading Crash Dumps with WinDbg + SOS — A Practical Guide to Analysis After Collection
Explains how to actually read a collected Windows crash dump using WinDbg and the SOS extension. Covers symbol path configuration, tracking exceptions and me...
-
Preventing Multiple Instances of a Windows App — Named Mutexes and Activating the Existing Window on a Second Launch
This article organizes the classic requirement for business Windows apps — 'don't let the same app launch twice' — around a named Mutex. We cover the pitfall...
-
Safely Calling Win32 APIs from C# — A Practical P/Invoke Guide (DllImport / LibraryImport / CsWin32)
A practical rundown of what to watch for when calling Win32 APIs and native DLLs from C# via P/Invoke. Covers the differences between DllImport and LibraryIm...
-
Integrating Entra ID Authentication into WinForms/WPF Apps — A Practical Architecture with MSAL.NET and the WAM Broker
A practical, hands-on look at integrating Entra ID (formerly Azure AD) authentication into WinForms/WPF desktop apps: the public client mindset, where ROPC s...
-
Date, Time, and Timezones in Business Apps — From DateTime Pitfalls to the UTC-Storage Principle and Test Design
Timestamps drift by nine hours after a server migration; only the overseas office's dates roll back to the previous day — we trace date/time incidents back t...
-
UI Automated Testing for Windows Desktop Apps — How UI Automation Works and Building Robust Tests with FlaUI
A practical guide to UI automated testing for WinForms/WPF apps, working from how Windows UI Automation itself works (the tree, AutomationId, control pattern...
-
WPF High-DPI Support — Why It Still Blurs and Bleeds Despite Being 'Supposedly DPI-Aware,' and How to Fix It
WPF lays out UI in DIPs (1/96 inch) and is System DPI Aware from the start, but moving a window to a monitor with a different DPI blurs the whole screen, and...
-
Why EXCEL.EXE Processes Remain After C# Excel COM Automation — Reference Release Patterns and the Replacement Decision
A practical look at why EXCEL.EXE processes remain running after automating Excel from C# via Microsoft.Office.Interop.Excel, explained through COM reference...
-
High-DPI Support in WinForms — Why the UI Blurs or Breaks on 4K Monitors, and Practical Fixes
This article organizes the reasons WinForms apps blur or have broken layouts on 4K monitors and 150% scaling, starting from DPI virtualization and DPI awaren...
-
Choosing Windows Inter-Process Communication ── A Decision Table for Named Pipes / TCP / gRPC / Shared Memory / COM
How do you choose the right way for Windows applications to talk to each other? This article organizes named pipes, local TCP, gRPC, shared memory, file-base...
-
Using SQLite from C# in Business Apps — WAL Mode, Exclusive Locking, Corruption Countermeasures, and When to Reach for EF Core
A practical rundown of embedding SQLite into a business Windows app with Microsoft.Data.Sqlite: connection strings and pooling, how WAL mode works, SQLITE_BU...
-
How to Build and Operate Windows Services ── From Choosing Between Task Scheduler and Services to Turning a BackgroundService into a Windows Service
Should a background process become a Windows service, or is Task Scheduler enough? This guide organizes the practical design work for putting a service into ...
-
How to Choose Where a Windows App Stores Local Data — A Decision Table for SQLite / JSON / Registry / Access
Where — and in what format — should a Windows desktop app store its data? This article organizes the choice between AppData and ProgramData, and the strength...
-
What Is a PDB (Program Database)? — Understanding Debug Information, Symbols, and Source Link
What a PDB (Program Database) file is, what it does and does not contain, and how it relates to Debug / Release, Portable PDB, Source Link, symbol servers, a...
-
What Is Roslyn? Reading, Fixing, and Generating C# Code from the Compiler's Point of View
An overview of Roslyn (the .NET Compiler Platform): Syntax Trees, SemanticModel, Workspaces, Analyzers, Source Generators, and where they fit (and where to b...
-
Windows App Outsourcing and Custom Software Development: What to Sort Out Before You Ask
Before commissioning Windows app outsourcing or custom software development, here is how to sort out existing software modification, device integration, COM/...
-
Using Algebraic Data Types in .NET Framework / .NET — Designing States and Results with Types
How to use algebraic data types — especially sum types and discriminated unions — in .NET Framework and .NET, and what you gain: F#, C# class hierarchies, re...
-
Handling Windows Impersonation Tokens Correctly — Borrowing Privileges per Thread and Reverting Safely
A practical guide to Windows impersonation tokens — access tokens, primary tokens, thread tokens, impersonation levels, RevertToSelf, and .NET's WindowsIdent...
-
The Misconception That TCP Lets You Receive in the Same Units You Send — Designing Reception Around a Byte Stream
Assuming TCP delivers data in the same units as Send or Write leads to fragmentation, coalescing, garbled text, and broken protocols. This article lays out h...
-
Telling GC Lag from a Memory Leak in .NET — A Practical Procedure for Observing, Comparing, and Proving Memory Growth
A procedure for determining whether growing memory in a .NET application is simply waiting on garbage collection or a genuine memory leak, using dotnet-count...
-
How to Run PowerShell from C# (CSharp) and Receive the Results as Objects
How to launch PowerShell from C# and receive results as PSObject rather than strings — a practical walkthrough of the PowerShell SDK, AddCommand, AddParamete...
-
A Checklist for Safely Handling Child Processes in Windows Apps
Handling child processes safely in a Windows app depends less on the launch API than on who owns the process tree and how shutdown is designed. This article ...
-
Serial Communication App Pitfalls - Through Reconnection and Log Design
The serial communication app pitfalls you want to avoid in device integration and instrument control, organized from a practical perspective: framing, timeou...
-
Choosing Between WinForms, WPF, and WinUI - A Practical Decision Table
How to decide between WinForms, WPF, and WinUI, organized from the perspectives of new development, existing assets, deployment, UI expressiveness, and team ...
-
Shared Memory Pitfalls and Practical Best Practices
The pitfalls of using shared memory in production, and a design that leaves fewer ways to go wrong across synchronization, visibility, lifetime, ABI, and per...
-
How to Fairly Compare the Execution Speed of C#, C++, Java, and Go
How to fairly compare the execution speed of C#, C++, Java, and Go, covering measurement design, warm-up, environment pinning, how to read the statistics, an...
-
Using a .NET 8 DLL from VBA with Full Typing - COM Exposure and dscom TLB
Call .NET 8 code from VBA with early binding: expose a class library to COM, generate a TLB with dscom, and register the comhost DLL. Sample code on GitHub.
-
Pre-Migration Checklist for Moving from .NET Framework to .NET
A practical checklist of what to verify before migrating from .NET Framework to .NET: project types, unsupported technologies, NuGet dependencies, SDK-style ...
-
What Is the .NET Generic Host? - The Foundation for DI, Configuration, and Logging
What the Generic Host does, seen through its relationship to DI, configuration, logging, IHostedService, and BackgroundService - and where it pays off versus...
-
What Is .NET Native AOT? - How It Differs from JIT and Trimming
What Native AOT is, sorted out against JIT, ReadyToRun, self-contained, single-file, trimming, and source generators, plus the cases it fits and the cases wh...
-
Choosing Between .NET's Three Timers - PeriodicTimer/Timer/DispatcherTimer
Which .NET timer should you use? PeriodicTimer for async loops, Timer for ThreadPool callbacks, DispatcherTimer for WPF UI, plus a decision table and code.
-
Calling a C# Native AOT DLL from C/C++
Publish a C# class library as a native DLL with Native AOT and call its UnmanagedCallersOnly entry points from C/C++ - where the setup fits, the implementati...
-
Why Use the .NET Generic Host and BackgroundService in Desktop Apps
How to use the Generic Host and BackgroundService to organize startup, periodic processing, shutdown, logging, configuration, and DI in Windows tools and res...
-
WPF/WinForms async and the UI Thread on One Sheet
After await in WPF or WinForms, which thread runs your code? Covers Dispatcher.Invoke, ConfigureAwait(false), and why .Result and .Wait() deadlock.
-
A Practical Guide to FileSystemWatcher - Handling Missed and Duplicate Events
We organize how to use FileSystemWatcher and its pitfalls - missed events, duplicate notifications, completion-detection traps, rescans, atomic claims, and i...
-
A Practical Decision Table for C# async/await - Task.Run and ConfigureAwait
C# async/await best practices, organized with a decision table that covers I/O waits, CPU work, Task.Run, ConfigureAwait(false), and fire-and-forget.
-
Calling Native DLLs from C#: C++/CLI Wrapper vs P/Invoke
When using a native DLL from C#, this article separates the cases where P/Invoke is enough from the cases where a C++/CLI wrapper pays off, looking at owners...