Site Contents | Weird .NET IssuesThis page briefly describes some weird issues you may encounter in the .NET Framework, with links to more detailed discussions. My criterion for selecting these issues was my own bafflement when I first encountered them.
Additionally, there are some weird .NET performance issues that I discuss elsewhere. User-defined value types can be surprisingly slow due to inadequate CLR JIT optimizers; and WPF drawing performance relies on disabling anti-aliasing and freezing all eligible objects. AnyCPU Versus Any CPU
If you look at a Visual Studio solution file, you’ll find that the .NET platform identifier for “pick x86 or x64 at runtime” is spelled
This is not because MSBuild ignores embedded spaces, as you will discover when you try to target A Microsoft Connect item has been opened for this issue – and closed as “Won’t Fix” in late 2009. Guess we’ll never see a fix for that one, so you simply have to be aware that projects require a different platform identifier than solutions. Application Settings Folders
The
Unfortunately, it also contains an error. Section “Settings File Location” claims that the configuration file for the current user is stored in the folder As it turns out, Application Settings creates a new folder for every new version of your application, and the folder name encodes the current version. The marked reply in this MSDN Forum thread explains the exact composition of the folder name.
If you wish your next application version to continue using the previous version’s settings, you must explicitly call an
On the other hand, if you wish Application Settings wouldn’t litter your file system with a hundred strangely named folders in the first place, you’re out of luck. The default WPF Focus Disables CommandsThis section covers two issues, both stemming from the bizarre way WPF handles input focus. The matter is discussed at length in the aptly titled MSDN Forums thread A FocusScope Nightmare. WPF windows distinguish multiple “focus scopes” which are predefined for menus and toolbars, and can be defined for any control via FocusManager.IsFocusScope. What the MSDN Library leads you to believe is that focus scopes can be created at will, to remember each focused element in various subsections of a window.
But in reality, it’s a very limited hack that’s just about good enough to make menus and toolbars work – while accidentally breaking routed commands. First, setting
Accidentally disabled commands are the other casualty of this design. Since the goal was to dispatch menu and toolbar commands to input controls in the main window, i.e. the parent focus scope, WPF simply disables any routed commands for menu and toolbar items whose targets cannot receive keyboard input – without even evaluating their
Fortunately, the workaround is just a few lines of code. During creation of your main window, loop through all menu and toolbar items and set their
|