System i Navigator Installer Corrupts Db Provider Factories

The IBM System i Navigator installer usually corrupts the DbProviderFactories node in the machine.config file. We have experienced this with both Version 6 and Version 7.

Possible Symptoms

  • Unable to use the IBM.Data.DB2.iSeries driver. Exception mentions DbProviderFactories.
  • Cannot see all of the Data Provider options when selecting a data source in a .NET application. OLE DB and SQL Server is usually available but custom providers such as IBM.Data.DB2.iSeries is not.
  • When connecting to a Team Foundation Server Project in Visual Studio get the following Error:
    • TF31001: Cannot connect to Team Foundation Server at xyz. The server returned the following error: Configuration system failed to initialize. Retry.
  • Any error related to DbProviderFactories

The problem

The installer usually leaves a hanging closing tag in the machine.config file, which corrupts your XML. Since your app.configs/web.configs inherit from this file, your configuration is corrupted also. Re-installing does not work.

The Solution

Check the following files for corrupted XML.

  • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\Machine.Config
  • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Machine.Config

The bad XML usually, but not always, looks like this. Remove the repeating closing tags and re-start your app.

Example of a corrupted machine.config file.
System i Series Navigator installer usually corrupts the machine.config file.

Topological Sorting in C#

I found an excellent article on Topological Sorting in C#. The class is pretty easy to understand and the article is excellent.

Why is this useful? Consider a data synchronization project that needs to distribute data to various systems. The order in which jobs execute matter because reference data has dependencies on one or more master data items, at potentially different levels in the hierarchy. Having a simple SortOrder property quickly becomes insufficient and difficult to manage for large job sets.

By performing a topological sort you can get the first group of items that have no dependency, the second group which depends on the first, and so on. The problem is reduced to a statement that looks like this:

//Get the groups
var groups = TopologicalSort.Group(Jobs, x => x.DependentOn, x => x.Id);

//Sort by the SortOrder property and return the groups
return groups.Select(x => x.Select(y => y).OrderBy(z => z.SortOrder ?? 0).ToList()).ToList();

Now your admin only has to set the dependency and trust that the system will find the correct execution order, in my example I added SortOrder for a little more tweaking. You as the developer can now focus on more interesting topics like parallel execution per group. 🙂

Check out the article and code at: