Friday, January 29, 2016

Configuring Tracing for your .NET applications

Thursday, January 28, 2016

Mail Merge Control for ASP.NET Web Forms and ASP.NET MVC

If you are looking for a Mail Merge Control for ASP.NET Web Forms and ASP.NET MVC, most of the controls out on the market today are based on Silverlight.

Fortunately, there is one vendor that supports Mail Merge with an HTML5 control and that vendor is Text Control:

They offer support for both ASP.NET Web Forms as well as ASP.NET MVC:

ASP.NET Web Forms:


When you need to deploy your Mail Merge control out to your web servers, you will need to follow this article:

In addition, it does not support some more advanced features of Mail Merge such as supporting Microsoft Word Document forms.

Nevertheless, it is definitely the best choice currently out there for an HTML5 Mail Merge control supporting both ASP.NET Web Forms and ASP.NET MVC.

Friday, January 22, 2016

Grant Administrative privileges to user accounts in TeamCity

If you are attempting to grant Administrative privileges to user accounts in Jetbrains TeamCity, it is not as readily obvious as you would think.

Under Administration for the specific User Account, there is a checkbox for "Give this user administrative privileges"

You check that checkbox and now that user has administrative rights in TeamCity!

Thursday, January 21, 2016

Ignoring error messages from Visual Studio Post Build events

I don't use Post Build events in my Visual Studio solutions very often since I prefer to code this directly into MSBuild as part of my Continuous Integration build process usually run by a CI Server such as Jetbrains TeamCity or Team Foundation Build.

However, since I work on a wide variety of projects as part of my consultancy, I frequently encounter projects which still leverage Visual Studio Post Build events.

A large number of Visual Studio projects have a Post Build event which redirects the output to another directory on the file system and may even include a set of commands needed to create the correct target directory structure.

The problem with this approach is using standard command line commands such as mkdir will emit errors if a directory already exists, thus causing Visual Studio to raise an error if a particular command in the Post Build event fails even though it may have worked just fine overall.

So, how do you handle this problem?

Well, using the capabilities of MSBuild, you can modify the Visual Studio project file to ignore these Post Build event error messages!

The solution provided here is by far my favorite solution to this problem:

It overrides the PreBuildEvent (or PostBuildEvent) target in order to ignore the exit codes or continue the Post Build event even if an error occurs.  Alternatively, you can even do both!

Once you include this target in your relevant Visual Studio project files, the Post Build event error messages you are encountering should disappear!

Keeping your Windows 8.1 and Windows Server 2012 R2 Installation images fully patched

If you have recently upgraded to Windows 8.1 or Windows Server 2012 R2 (or later), you may now require some tooling to ensure you can keep your Windows images fully patched as you build out new OS systems and images.

You may have read my earlier post regarding Windows 7 and Windows Server 2008 R2 here:

Unfortunately, many of the tools listed in that article are no longer viable solutions for Windows 8.1 and later OSes.

Thankfully, though, there are a few suitable replacements to these earlier outdated tools!

While Windows Updates Downloader has not kept up with the Windows 10 updates, it still has a relatively recent list of updates for Windows 8.1:

A newer alternative to Windows Updates Downloader is now called WHDownloader and can be downloaded from here which also uses Update Lists:

Another recent and well-maintained tool is WSUS Offline Update:

The updates on the WSUS Offline Update site seem to be much more regularly and frequently updated than the Update Lists provided on Windows Updates Downloader (which has not had its last update since March 2015).

When you are ready to finally integrate these Windows Updates into your Windows media, you can grab a tool such as NTLite to easily help you integrate these patches/updates directly into your Windows media!

Setting up Outlook with your Office 365 account

I just got an Office 365 account for the very first time the other day so when I wanted to check my e-mail via Outlook, naturally, when I attempted to connect Outlook directly, it did not work!

This, of course, sent me on a hunt to find out the correct settings to hook up my Outlook Mail client with my Office 365 Mail account which I conveniently found here:

PowerShell scripting support for Pre and Post Build events in Visual Studio

If you love PowerShell scripting vs. writing plain old command-line scripts like me, then you will be disappointed to learn that Visual Studio does not offer native support for PowerShell scripts in either Pre or Post Build events.

Instead, you are still left with standard command line macros and commands which are much more inflexible and brittle than PowerShell scripts.

Therefore, if you also want to see native PowerShell scripting support added to the Visual Studio IDE for supporting Pre and Post Build events, you should definitely vote for this UserVoice item here!

You need to install the latest Silverlight Developer Runtime

I recently had to build a Silverlight project in Visual Studio and when I attempted to compile my solution, I received the following error message:

The error message directed me to download and install the Silverlight Developer runtime from this Url:

Once I did this and installed the Silverlight Developer runtime on my machine, I was able to successfully build the solution!

What are the NuGet v. 2 and v. 3 Urls?

I have found myself recently having to bounce back and forth between Visual Studio 2013 and Visual Studio 2015 and if you have not already discovered this for yourself, they use different versions of NuGet as well as different NuGet Urls!

Therefore, when I am setting up Autobuilds in a CI Build Server such as Jetbrains TeamCity, I usually need to configure the appropriate NuGet Server Urls in order to ensure all of the correct NuGet packages are downloaded at build time.

So I needed to know the different NuGet Urls used by the different versions of NuGet!

Well, for NuGet v. 2.x, the Url is the following:

If you are using NuGet v. 3.x, the Url is slightly different as follows:

You can then configure these respective Urls in Visual Studio and your CI Build Server to ensure that all of the NuGet packages are downloaded and restored correctly!

Wednesday, January 20, 2016

Supporting Visual Studio Installer projects

If you are upgrading from an older version of Visual Studio (such as Visual Studio 2010) to Visual Studio 2013 or Visual Studio 2015, you may find that, by default, these newer versions of Visual Studio no longer support Visual Studio Installer Projects (.vdproj files)!

Fortunately, though, Microsoft has heard our complaints and has addressed this problem by releasing a Visual Studio Extension for both of these IDEs to allow these project types to be opened once again!

Microsoft Visual Studio 2013 Installer Projects

Microsoft Visual Studio 2015 Installer Projects

Once you have installed one of these extensions, you will once again be able to open your Visual Studio Installer Projects!

Thursday, January 7, 2016

Download older releases of Java

If you are using some software application which is still dependent on an older release of Java, it may be difficult to find where to locate these earlier releases of Java.

Fortunately, the Oracle website provides an archive of most of the older Java releases such as Java 1.7 here:

Unfortunately, in order to download these older releases, you will need to use an Oracle account or sign up for a new Oracle account. :-(

Big changes coming to ASP.NET 5/MVC 6!

You have probably read a lot of hype about the big changes coming to ASP.NET 5/MVC 6 and now that ASP.NET 5 is in Release Candidate, the RTM release is very near on the horizon.

So you might be interested in what is coming for the future RTM release of ASP.NET 5/MVC 6.

If you look at the roadmap for ASP.NET 5, you can see that it is scheduled to be released in the next few months of this year:

If you want to get started reading articles about ASP.NET 5, you can go through the ASP.NET vNext site here:

However, if you are most interested in what to expect in terms of changes with ASP.NET 5, you should definitely check out this article:

Some of the very interesting points to note is that VB.NET will no longer be an out-of-the-box supported language!  C# will be the primary language of choice for ASP.NET 5!

Another major difference is the removal of ASP.NET Web Forms support.  While ASP.NET Web Forms will continue to be supported on .NET Framework v. 4.6 with Visual Studio 2015, it seems that the trend is not to continue the product in active development going forward.

Another big change is that the MSTest framework is essentially going away to be replaced by xUnit.NET!

I have been using MSTest since the very first release with Visual Studio 2005 and have been using it ever since.  Though I have occasionally used nUnit in the past, I have never played around with xUnit.NET thus far, so I have to begin transitioning over to this new Unit Testing Framework as part of my preparatory training for ASP.NET 5/MVC 6!

Configuring a fresh/clean Windows Server for software installations

I frequently have to work on setting up Windows Server for either installation or development purposes, so I usually have to repeat a common set of steps over and over on all of the servers that I set up.  When I set up and configure my own servers or virtual machines, I have all of this scripted and imaged so that I can set up my environments within a matter of minutes, but I usually have to repeat these same steps on environments built by other companies/network administrators, so I do not always have the luxury of using my own set of images as a base configuration.

Therefore, I usually have to perform many of these steps manually.

Here are the common steps that I follow when setting up any Windows server environment for my development and installation purposes:

  1. If the server is an older server such as Windows Server 2008 R2, I will usually have to install .NET Framework v. 4.5.2 and Windows PowerShell v. 4.0
  2. In many cases, I have to go in and turn off Internet Explorer Enhanced Security so that I can download any additional software that I need.
  3. I usually need to test and verify connectivity to other servers, so I will usually install the Windows Server Feature for Telnet Client.
  4. I then proceed to install my most commonly used alternative browsers such as Google Chrome 64-bit and Mozilla Firefox 64-bit.
  5. On some Microsoft sites, I have problems downloading their software due to restrictions in providing a mix of secure and insecure content on Google Chrome and Mozilla Firefox, so I install Opera browser as my backup in the event that one of these other browsers cannot download some Microsoft-specific content.
  6. I go into Windows Firewall and open any ports or allow any programs that I will need to use for my installation and development purposes such as for FTP, SMTP, SQL Server, Oracle etc.
  7. I run PowerShell an initial time to make sure that the ExecutionPolicy is set to either RemoteSigned or Unrestricted (Set-ExecutionPolicy -ExecutionPolicy RemoteSigned)
  8. I use the PowerShell ISE frequently, so I usually pin an instance of PowerShell ISE to my Windows Taskbar.  I also configure the PowerShell ISE properties to "Run as Administrator" by default.
  9. I usually use the Command Prompt very frequently as well, so I end up pinning that to the Windows Taskbar also and configure the properties to "Run as Administrator" just as I do with the PowerShell ISE.
  10. I like to have a backup PowerShell IDE available for my development other than PowerShell ISE, so I will also install Idera PowerShell Plus, pin it to my Windows Taskbar and set it to "Run as Administrator".  
  11. In the event I may have to install software from an ISO image, I usually install ISO mounting software such as Elaborate Bytes Virtual CloneDrive.
  12. More often than not, I also require an FTP client at some point in time, so I will usually install the FileZilla 64-bit FTP client.
  13. When I am doing some sort of installation or development, chances are that I will need to perform some types of file or folder comparisons at some point in time, so I will usually install a file comparison utility such as Scooter Software's Beyond Compare or Sourcegear's DiffMerge.
  14. Most instances of servers that I set up require either SQL Server or tools to manage SQL Server, so I will also usually install SQL Server Management Studio (at a minimum).  
  15. Most Windows servers I set up end being ASP.NET Web Servers, so I run a PowerShell script to install IIS and its associated features for ASP.NET.
  16. I am usually very dissatisfied with using Notepad as my text editor of choice, so I will also frequently install Notepad++.
Once I have all that in place, I am ready to begin my Windows server installations!

Tuesday, January 5, 2016

Where is the tnsnames.ora file?

I haven't used Oracle in quite a few years so when I was looking for the tnsnames.ora file, it was not readily obvious where I could find it.

I eventually found the tnsnames.ora file at this location:


Creating a tnsnames.ora file using PowerShell

I recently began working with Oracle again after a long span of time and decided that I would make my life easier by trying to script setting up Oracle connections using my newfound knowledge of PowerShell.

Fortunately, I came across this article which accomplishes this rather handily:

Of course, I wanted to modify the code to suit my needs a bit better to allow me to write the tnsnames.ora file to the required [Oracle Home]\network\admin\tnsnames.ora file path, so I modified the PowerShell script as follows:

 [string] $Name,
 [string] $Protocol = "TCP",
 [string] $Hostname,
 [string] $Port = "1521",
 [string] $Sid,
 [Parameter(Mandatory=$true,HelpMessage="Provide the tnsnames.ora file path")]
    [System.IO.FileInfo] $File

function Get-OracleDataSources
    $f = [System.Data.Common.DbProviderFactories]::GetFactory("Oracle.DataAccess.Client")
    if ($f.CanCreateDataSourceEnumerator)
        $e = $f.CreateDataSourceEnumerator()                                                                              

function Out-TnsAdminFile
        [System.Object[]] $Entries,
        [System.IO.FileInfo] $File = $(throw "Parameter -File <System.IO.FileInfo> is required.")
        if ($File.Exists)
            $originalEntries = @(Get-TnsAdminEntries $File.FullName)
        if ($_)
            $Entries = @($_)
        $Entries | % {
            $entry = $_
            $existingEntry = $originalEntries | ? {$_.Name -eq $entry.Name}
            if ($existingEntry)
                $existingEntry.Name = $entry.Name
                $existingEntry.Protocol = $entry.Protocol
                $existingEntry.Host = $entry.Host
                $existingEntry.Port = $entry.Port
                $existingEntry.Service = $entry.Service
                $originalEntries += $entry
        $originalEntries | % {
            $entry = $_
            $Name = $entry.Name
            $Protocol = $entry.Protocol
            $Hostname = $entry.Host
            $Port = $entry.Port
            $Service = $entry.Service

            [string] $text += @"
$Name =
      (ADDRESS = (PROTOCOL = $Protocol)(HOST = $Hostname)(PORT = $Port))
      (SERVICE_NAME = $Service)

  New-Item -Path $File.FullName -ItemType "File" -Force
  $text | Out-File $File.FullName -Encoding ASCII
        Remove-Variable text
    end {}

function Get-TnsAdminEntries
        [System.IO.FileInfo] $File
    begin {}
        if ($_)
            $File = [System.IO.FileInfo] $_
        if (!$File)
            Write-Error "Parameter -File <System.IO.FileInfo> is required."
        if (!$File.Exists)
            Write-Error "'$File.FullName' does not exist."
        [string] $data = gc $File.FullName | ? {!$_.StartsWith('#')}
        $pattern =  '(?<name>^(\w)+[\s]*?)|\)\)(?<name>\w+)|HOST=(?<host>\w+)|PORT=(?<port>\d+)|PROTOCOL=(?<protocol>\w+)|SERVICE_NAME=(?<service>\w+)'
        $patternMatches = [regex]::Matches($data.Replace(" ", ""), $pattern, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
        $tnsEntries = @()
        for ($i = 0; $i -lt $patternMatches.Count; $i++)
            if ($i -eq 0 -or $i % 5 -eq 0)
                $tnsEntry = New-Object System.Object
                $tnsEntry | Add-Member -type NoteProperty -name Name     -value $patternMatches[$i + 0].Groups["name"].value
                $tnsEntry | Add-Member -type NoteProperty -name Protocol -value $patternMatches[$i + 1].Groups["protocol"].value
                $tnsEntry | Add-Member -type NoteProperty -name Host     -value $patternMatches[$i + 2].Groups["host"].value
                $tnsEntry | Add-Member -type NoteProperty -name Port     -value $patternMatches[$i + 3].Groups["port"].value
                $tnsEntry | Add-Member -type NoteProperty -name Service  -value $patternMatches[$i + 4].Groups["service"].value
                $tnsEntries += $tnsEntry
    end {}

$tnsEntry = New-Object System.Object

$tnsEntry | Add-Member -type NoteProperty -name Name     -value $Name
$tnsEntry | Add-Member -type NoteProperty -name Protocol -value $Protocol
$tnsEntry | Add-Member -type NoteProperty -name Host     -value $Hostname
$tnsEntry | Add-Member -type NoteProperty -name Port     -value $Port
$tnsEntry | Add-Member -type NoteProperty -name Service  -value $Sid

$tnsEntry | Out-TnsAdminFile -File $File

Friday, January 1, 2016

Resetting an AutoNumber field in Microsoft Access

I was recently working with Microsoft Access to store some basic data and I wanted to reset an AutoNumber field in my MS Access database, so I found this article which described just how to do that!

How to reset an AutoNumber field value in Access