On production machine: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts.

I was helping my colleagues to debug one weird bug on ASP.NET 4.0 website. Everything worked well on developer’s machine, but after publishing to IIS 7.5 Windows 2008 R2 Webserver, we always got site partially working. Everything worked, except AJAX Control Toolkit controls.

There were no any signs of errors. Ajax controls just were not functioning. Digging deeper, we found, that JavaScript is throwing exceptions:
SCRIPT5022: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.

This is the most common error with AJAX Control Toolkit — you need to use ToolkitScriptManager instead of ScriptManager. Read more here.

But in our case we was already using ToolkitScriptManager in the all places in our source code.

Digging deeper we found that there is a bug in Script Manager, that is trying to load all DLLs in the project’s bin folder. Script Manager is trying to load DLL files even if they are not used in the project. [I know, that it is not best practice, to keep files not used by project on the production server, but that’s another story.]

The solution was plain and simple: remove all unused DLLs from production machine’s bin folder.

More info about bug and the same problem in different product:

C++ now allows to forward declare enum(s)

Thanks to recently approved standard (C++11 / C++0x), it is possible to forward declare enums. It was possible with classes for the long time, for example, “class MyClass;” in C++ [forward] declares class without providing underlying details. For enums it was not possible, because compiler needed to know exact size of the enum.

Below are details from Wikipedia:

Forward-declaring enums is also possible in C++11. Previously, enum types could not be forward-declared because the size of the enumeration depends on the definition of its members. As long as the size of the enumeration is specified either implicitly or explicitly, it can be forward-declared:

enum Enum1; // Illegal in C++03 and C++11; the underlying type cannot be determined.
enum Enum2 : unsigned int; // Legal in C++11, the underlying type is explicitly specified.
enum class Enum3; // Legal in C++11, the underlying type is int.
enum class Enum4 : unsigned int; // Legal C++11.
enum Enum2 : unsigned short; // Illegal in C++11, because Enum2 was previously declared with a different underlying type.

.NET text box blank/empty/invisible/hidden when text reaches certain length

It seems, that .NET 2.0 have bug when text box (TextBox control) appears blank / empty / invisible / hidden — not showing text when text length reaches certain size. My quick tests shows, that the length of the text that causes this bug to appear depends on something and are changing from program to program or from computer to computer. Unfortunately I do not have resources to test this bug in full right now.

How to repeat this bug in C# .NET 2.0.

Open Visual Studio and create New Project – Windows Forms Project.

Create a new .NET 2.0 project

Add one TextBox and two Buttons to the project.

Form with 2 Buttons and TextBox

Add click handlers for two buttons and one helper function. Here is a code.

      private void button1k_Click(object sender, EventArgs e)
         textBox.Text = GenerateString(1000);
      private void button10k_Click(object sender, EventArgs e)
         textBox.Text = GenerateString(10000);
      private string GenerateString(int lenght)
         string text = "";
         for (int i = 0; i < lenght; ++i)             text += Convert.ToChar('0' + i % 10);          return text;       }

Now run the code! Clicking on the first button, TextBox shows some random numbers as expected.

Correct result, text is shown

Now click on the second button. Text disappears, and only blinking cursor is shown. Also note, that TextBox is functioning -- you can still delete / add characters, select all, use copy / paste, you just do not see the results on the screen.

Incorrect result, only cursor blinks

Workarounds? Currently none. Submitted this bug to Connect: .NET 2.0 TextBox fails to display long texts.

Tested on Windows 7 Pro 64-bit and Windows 7 Ultimate 64-bit with latest updates on 12/2/2011. Compiled with latest Visual Studio 2010 Pro 10.0.40219.1 SP1Rel w/ Microsoft .NET Framework Version 4.0.30319 SP1Rel.

P.S. One similar bug is reported on Microsoft Connect, however it seems like separate issue: Vanishing text bug.

P.S.S. My source code can be downloaded from MS Connect.