I have a class containing something like the following:
public static class Config
{
private static Lazy<ConfigSource> _cfgSrc = new Lazy<ConfigSource>(
() => { /* "ValueFactory" here... */ },
true);
public static ConfigSource ConfigSource
{
get { return _cfgSrc.Value; }
}
}
In accessing the ConfigSource
property, I encountered this InvalidOperationException
:
ValueFactory attempted to access the Value property of this instance.
I don't see anything in my "value factory" method that accesses the Value
property. Is there anything else that could be triggering this exception? This problem only happens intermittently, but once it does, it takes resetting IIS to clear up the Exception (which appears to be cached once it occurs).
question from:
https://stackoverflow.com/questions/6300398/invalidoperationexception-in-my-lazy-value-factory 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…