Posts Tagged ‘visual studio 2010’

Windows Forms Designer gives “Value does not fall within expected range” error

Friday, September 3rd, 2010

I was working on a project that I’ve been working on for a very long time in Visual Studio 2010.  I opened a designer and got the error “Value does not fall within expected range”, which was accompanied by a particularly useless stack trace and a dead link to a help article.

Cleaning the solution, closing Visual Studio and reopening it seemed to fix it for me.  Hope this helps!

Extension Methods stop working!?

Wednesday, August 11th, 2010

I’m working on a solution where I have several different projects. Some of these projects are class libraries (DLLs) and some projects reference others. In some of them I have a number of extension methods.

I’ve noticed something strange happening occasionally. The extension methods in one of the class libraries stop functioning as extension methods for no apparent reason. This is even if they are called from within the same class library. It is usually after I have changed something, but not anything significant, and the namespace references all appear to be correct when I check. This isn’t just intellisense either – the build fails compilation.

The simple solution to this problem that I have found (which may solve other weird compilation bugs as well) is simply to clean the solution, close Visual Studio, reopen it and build again. This has worked every time that I’ve tried it so far.

This applies to Visual Studio 2010 Professional, and possibly 2008 as well, but I can’t remember if I had that problem then.

Unhandled exception clr20r3 mxyabj2rsfg4uknkgmspj2kfpmzxhcc5

Tuesday, August 3rd, 2010

A few weeks ago, I hit a problem that an application that I wrote suddenly started randomly dropping out with an unhandled exception. I can’t remember all the specifics anymore, but I do remember that the event that was written to the logs (that can be viewed in Event Viewer in Administrative Tools in Control Panel): –

EventType : clr20r3
P9 : mxyabj2rsfg4uknkgmspj2kfpmzxhcc5

The most confusing thing about this was that I have a system built in to the application to catch unhandled exceptions, and this had been working fine in the past for a few years. I couldn’t understand why it wasn’t catching this exception.

What was even more confusing was that it was randomly affecting several machines in different sets of circumstances. I eventually managed to find something that would reliably reproduce the problem, but when I tried it on my development PC in the debugger, it worked fine (I still haven’t worked out why this is).

I initially thought that maybe it was because I had just upgraded to Visual Studio 2010 and tried to back-convert my application back to Visual Studio 2008, but the problem continued. I also tried using remote debugging to track down the problem, which also caused a lot of problems as the application still seemed to be dropping out even with the remote debugger running!

I eventually tracked down the problem using a Try, Catch clause around code which I knew would reproduce the problem. The exception was about a missing resource file. I hunted around and eventually found that the resx file for the error handling dialogue window seemed to have been excluded from the project, presumably due to some bug while it was being upgrade to Visual Studio 2010.

After I put the resx file back, I was able to see that the application was throwing an exception. My code for dealing with the unhandled exception had caught it and been throwing the other exception, which didn’t have anything to catch it, so the Common Language Runtime (or Windows?) killed it.

Edit: The actual exception type that was being thrown was System.Resources.MissingManifestResourceException