There is already an open DataReader

Every once in a while I get an Exception message emailed to me concerning one of my sites stating “There is already an open DataReader associated with this Command which must be closed first.” I cannot get the error to occur no matter what I try but the issue usually happens when I get hit by a russian web crawler (yandex) or rarely something else that hits multiple pages at once. Today’s message continuously pointed to my ByName() which is below.

private static Func<mvCmsContext, string, Configuration> _byName =
	CompiledQuery.Compile((mvCmsContext context, string configName) =>
		(from c in context.Configs
		 where c.configName == configName
		 select c).SingleOrDefault());
static public Configuration ByName(string configName)
	var result = (Configuration)HttpContext.Current.Cache.Get(configName);
	if (result == null)
		result = _byName(context, configName);
		HttpContext.Current.Cache.Insert(configName, result);
	return result;

The ConfigRepository (and everything else) is run though Castle Windsor IoC container with a Transient lifestyle so it should close the DataReader, correct?

I’m stumped on this one. Any ideas? If I could get it to happen I imagine it would be easier to troubleshoot.

Ah, I think I’ve got it. I took an easy way out and put my configService available on the masterpage and so I didn’t end up running it through the IoC container after all. Hrump! I’ll have to fix that. :frowning:

I’ve been out of this for so long I’m having a lot of trouble with it. This stinks. I should have run the static config strings through a partial view instead of just being lazy.