Sharing DLLs with multiple programs without versioning issues

Modern day internal .NET applications combine services, console applications, unit tests, winforms and asp.net web applications. These applications often share Assemblies (DLLs). With so many exe’s, updating our applications can be quite a challenge. For one thing, Visual Studio is designed to output a program with one top level exe file. Modern day applications consist [...]

Factory Design pattern – simple example

Factory patterns can be used to select classes at runtime without specifying a class name. In order to achieve this awesome task, we actually work with an Interface rather than the types that implement the interface. using System; using FactoryPattern; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { RunFactory(); } private static [...]

working with C# and C++

Today a programmer asked “how can I make my unmanaged C++ DLL into a managed C++ DLL so C# can use it”. First of all, C# can call unmanaged C++/ANSI with PInvoke via DLLImport. This is important to note because making Ansi C++ into managed C++ (CLI) can be a pretty intensive task. Here’s a [...]

The Pragmatic Bookshelf and avoid Programming by Coincidence – terribad idea

Today I read a piece off “The Pragmatic Bookshelf” entitled “Programming By Coincidence“. I am honestly scared that people desire staff with the mindset this article recommends. The article begins with a metaphor relating programming to war. Basically, programming becomes crossing a “minefield” where the best solution is to stab every square inch of ground [...]

Where do app.config files go?

An app.config file is a great way to store data that may need to be updated without requiring a recompilation. But, where do app.config files go? In class library solutions/DLLs, in executeable files, in either? With one exception, app.config files should be added to the project that produces the executable file. When you build the [...]

Gathering ipaddress and other network information from IPConfig with C#

IPConfig offers some great information about our network cards. But, its not very friendly to use when you are programming. You could parse the output using a regular expression, but this is kinda sloppy and sensitive to any future upgrades or textual differences between operating systems. Instead, we can use WMI queries to ask the [...]

How to check permissions for a web service or other service account

I recently ran into a suspected permission issues with a web service’s account. Being that the service account did not have the “logon locally” account priviledge I had to find another way to test my theory. I implemented some code I found on MSDN. I programmatically logged into another user account. The account info is [...]

Synchronizing Threads using Wait Handles

Synchronizing threads can be done in many ways. Static counters, locks, and wait handles to name a few. In this example I review the use of wait handles. Wait Handles can keep threads from running until they receive a signal to do so. There are two types of wait handle classes in .NET: AutoResetEvent and [...]

How to communicate across different sql server instances

I recently had the requirement to synchronize two tables in two different sql server instances. After a little research I discovered that this can be done with a linked server. After setting up a linked server one can call another database instance with the same familiar T-SQL syntax. SELECT * FROM [SERVER\MyInstanceName].[DatabaseName].[TableName] (or just [SERVER] [...]