.NET Framework 4.5.1 Broke .NET 4.0 Application


Recently we installed the latest Windows Updates; one of the updates installed .NET Framework 4.5.1!

After installing the updates, .NET 4.0 Web API project stopped working. Following three errors were reported in the logs generated by the application; this is the same code that was running fine before the updates were installed! Please note that each of the following was a separately reported exception which occurred when the code was trying to open a connection to the database.

  • System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  • System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
  • System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 – The message received was unexpected or badly formatted.) —> System.ComponentModel.Win32Exception (0x80004005): The message received was unexpected or badly formatted

The following errors were found in the Applications event log.

Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2
Faulting module name: System.Data.dll, version: 4.0.30319.18408, time stamp: 0x52310bef
Exception code: 0xc0000005
Fault offset: 0x000000000002ca0c
Faulting process id: 0x1c44
Faulting application start time: 0x01cf160933711ff2
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll
Report Id: b43e16a4-81fd-11e3-9401-d4ae5267f94a

Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: w3wp.exe
P2: 7.5.7601.17514
P3: 4ce7afa2
P4: System.Data.dll
P5: 4.0.30319.18408
P6: 52310bef
P7: c0000005
P8: 000000000002ca0c
P9:
P10:

Attached files:

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_w3wp.exe_1dabd81cc049f8988c7cfa9798cf58f89514c50_0970896a

Analysis symbol:
Rechecking for solution: 0
Report Id: b43e16a4-81fd-11e3-9401-d4ae5267f94a
Report Status: 4

Research on Google didn’t help much because different people received these errors in different contexts and the solutions/tips varied from restarting the computer to changing the way we access the database! We didn’t want to touch the code because this application was working moments ago! There has to be something in the Windows Updates that broke the application.

Painstaking review of the Windows Updates which were installed that day couldn’t result in anything important that would help narrow down to a particular update.

image

Then all of a sudden, the light bulb moment! I remember seeing .NET Framework 4.5.1 in the list of updates Windows wanted to install but it wasn’t in the above list! So where did it go? It was found in the “Add/Remove Programs” area. Before we could uninstall it, we wanted to check whether that is the culprit. Little research on .NET Framework 4.5.1 lead us to the KB2915689 which talks about one of the errors we were getting!

image

We tried the first workaround by disabling the Sophos Antivirus which had several BSP/LSP installed on the server but no use; the application still threw the same errors.

The second workaround was to uninstall .NET Framework 4.5.1 and we did just that! Please make a note of the following gotchas (originally listed here) before you install or uninstall .NET Framework 4.5.1

  • The .NET Framework 4.5.1 is an in-place update to the .NET Framework 4.5.
  • The .NET Framework 4.5 and .NET Framework 4.5.1 replace the .NET Framework 4. When you install these versions on a system that has the .NET Framework 4 installed, the assemblies are replaced.
  • Uninstalling the .NET Framework 4.5 also removes pre-existing .NET Framework 4 files. If you want to go back to the .NET Framework 4, you must reinstall it and any updates to it. (See Installing the .NET Framework 4.)

In a nutshell, we were able to run the application again by following these steps:

  1. Uninstall the .NET Framework 4.5.1
  2. Install the .NET Framework 4.0
  3. Update the Application Pool for the particular application to use .NET 4.0 (apparently uninstalling 4.5.1 changed it to .NET 2.0)

Mobile-friendly Server Interfaces


Watched this video on InfoQ about designing APIs for the mobile applications. Few good tips and insights I gathered after watching it are as follows.

  1. Things to consider while designing the mobile APIs
    • Battery life
    • Latency
    • Chunky vs. Chatty
  2. gZip data, especially JSON.
  3. Instead of loading everything in one go, think about loading data on events.
  4. Should the application (hence the APIs) be optimized for reading or writing or both?
  5. Have caching strategy in place. Cache, not only on the client side, but also on the server side.
  6. Granular, true REST interfaces are great but you might end up making several calls to get the data your screen needs. You might have to create screen specific APIs ( the APIs that provide data and services for one screen ) in order to reduce the # of calls made to the server.
  7. Pre-generate or pre-process and cache the data that you think the application might need.
  8. Offload work to the client.