VMware Horizon Community
nickvane
Contributor
Contributor

Changing CurrentUICulture in a .net 4.0 app on Win7 leads to infinite loop (and memory leak)

We've recently upgraded one of our business applications from .net 3.5 to .net 4.0. We're using ThinApp 4.6.0 to virtualize our application.
When starting the virtualized application on Windows 7 it continuously consumes memory until an OutOfMemoryException occures. This does not happen when the application is not virtualized. This does not happen on Windows XP or Windows Vista. This didn't happen when the application was on .net 3.5 and virtualized.

We managed to pinpoint it down to 1 call in the .net framework that uses a method from kernel32: GetLocalInfoEx

We think the delegation from the result of this method through the ThinApp layer is incorrect.

About the change from .net 3.5 to .net 4.0: http://msdn.microsoft.com/en-us/netframework/dd890508 (see diagram Globalization Properties Architecture in .NET Framework 4)

In attachment is a zip file with an application that simulates the problem. It's a console application consisting of this code:

class Program
{
  static void Main(string[] args)
  {
    var cultureInfo = Thread.CurrentThread.CurrentUICulture;
    Console.WriteLine("Current UI culture: '" + cultureInfo.Name + "'");
    cultureInfo = cultureInfo.Parent;
    Console.WriteLine("Parent of current UI culture: '" + cultureInfo.Name + "'");
    cultureInfo = cultureInfo.Parent;
    Console.WriteLine("Parent of the parent of current UI culture: '" + cultureInfo.Name + "'");
    Console.ReadLine();
  }
}

The compiled app is in the zip as well as the virtualized app. The ThinApp monitor log files are also provided in the zip file.

Calling the parent of the CultureInfo in a non-ThinApp build results in:

Current UI culture: 'en-US'

Parent of current UI culture: 'en'

Parent of the parent of current UI culture: ''

The ThinApp build of the application results in:

Current UI culture: 'en-US'

Parent of current UI culture: 'en-US'

Parent of the parent of current UI culture: 'en-US'

When we set the CurrentUICulture to something else (nl-BE) this creates an infinite loop in a function in the .net framework when the ToString method of an exception is called, because that function loops over the parent of the CultureInfo and retrieves the same value.

We can't work around the issue in our application as we need to set the CurrentUICulture. Can we work around this issue by modifying the build process? Or is there a fix for this issue?

Tags (3)
Reply
0 Kudos
0 Replies