Installing DLL Into GAC Using Powershell

To install DLL into Global Assembly Cache (GAC) you need Visual Studio or SDK to run gacutil.exe. It’s not convenient when you need to deploy ASP.NET application in IIS. This time you can do this with Powershell as described in TechNet article How to Install a DLL to the GAC on Windows Server 2012 Using Only PowerShell by Muhammad Khalid Latif.

Line Number In C# Program

I have a method in ASP.NET application that works good but sometimes it fails. I need some kind of error logging or tracing. If you don’t want to write stupid messages everywhere in your code, you have some possibilities.

In debug mode:
1. Embrace your code in try-catch block. Compile the application in debug mode and place .pdb file along with .exe file. When the error is occurred, exception will show the line number.
2. You can write trace info manually as described by Scott Hanselman in Getting the Line Number and File Name from C#.

.pdb file is necessary here, or you’ll see 0 instead of a line number.

In release mode:
Thanks to Marc Gravell, but you need .NET Framework 4.5 or higher here.

SQL Scalar Functions – MIN of Multiple Values

SQL Server built-in function MIN() is an aggregate function. It can find minimal value on a single column from many rows.
To find minimum of multiple columns you can write UDF or use a subquery.

Important! My examples works fine even with nullable values, i.e. they ignore null values and return a minimum only from concrete values. If all values are null, they return null.

1. Scalar function for two values

2. Scalar function for three values

It can be quite hard to write a function for more input values. You can use a subquery here.