axuno / SmartFormat

A lightweight text templating library written in C# which can be a drop-in replacement for string.Format
Other
1.1k stars 105 forks source link

Error: ValueFactory attempted to access the Value property of this instance. #271

Closed msmart closed 2 years ago

msmart commented 2 years ago

Smart.Format version: 3.0 Framework version: net6.0

I am aware that this is not a helpful bug report. But any pointers on how to debug/resolve this and identify the root cause would be greatly appreciated.


@timestamp @message
2022-04-01 00:19:59.783 at Project.Localization.Localizer.get_Item(String name, Object[] arguments) in /src/Project.Localization/Localization/Localizer.cs:line 119, format:with {0}., argumentsSystem.Object[]
2022-04-02 00:19:59.783 at SmartFormat.SmartFormatter.Format(IFormatProvider provider, String format, IList`1 args)
2022-04-02 00:19:59.783 at SmartFormat.Core.Parsing.Parser.ParseFormat(String inputFormat)
2022-04-02 00:19:59.783 at SmartFormat.Pooling.SmartPools.ParsingErrorsPool.get_Instance()
2022-04-02 00:19:59.783 at System.Lazy`1.CreateValue()
2022-04-02 00:19:59.783 --- End of stack trace from previous location ---
2022-04-02 00:19:59.783 at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
2022-04-02 00:19:59.783 Error localizer Smart.Format: System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
2022-04-02 00:19:59.772 Error localizer Smart.Format: System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
2022-04-02 00:19:59.772 at Project.Localization.Localizer.get_Item(String name, Object[] arguments) in /src/Project.Localization/Localization/Localizer.cs:line 119, format:{0}, argumentsSystem.Object[]
2022-04-02 00:19:59.772 at SmartFormat.SmartFormatter.Format(IFormatProvider provider, String format, IList`1 args)
2022-04-02 00:19:59.772 at SmartFormat.Core.Parsing.Parser.ParseFormat(String inputFormat)
2022-04-02 00:19:59.772 at SmartFormat.Pooling.SmartPools.ParsingErrorsPool.get_Instance()
2022-04-02 00:19:59.772 at System.Lazy`1.CreateValue()
2022-04-02 00:19:59.772 --- End of stack trace from previous location ---
2022-04-02 00:19:59.772 at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
2022-04-02 00:19:59.772 at Project.Localization.Localizer.get_Item(String name, Object[] arguments) in /src/Project.Localization/Localization/Localizer.cs:line 119, format:{0}, argumentsSystem.Object[]
2022-04-02 00:19:59.772 at SmartFormat.SmartFormatter.Format(IFormatProvider provider, String format, IList`1 args)
2022-04-02 00:19:59.772 at SmartFormat.Core.Parsing.Parser.ParseFormat(String inputFormat)
2022-04-02 00:19:59.772 at SmartFormat.Pooling.SmartPools.ParsingErrorsPool.get_Instance()
2022-04-02 00:19:59.772 at System.Lazy`1.CreateValue()
2022-04-02 00:19:59.772 --- End of stack trace from previous location ---
2022-04-02 00:19:59.772 at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
2022-04-02 00:19:59.772 Error localizer Smart.Format: System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
2022-04-02 00:19:59.771 Error localizer Smart.Format: System.InvalidOperationException: ValueFactory attempted to access the Value property of this instance.
2022-04-02 00:19:59.771 at Project.Localization.Localizer.get_Item(String name, Object[] arguments) in /src/Project.Localization/Localization/Localizer.cs:line 119, format:{0}, argumentsSystem.Object[]
2022-04-02 00:19:59.771 at SmartFormat.SmartFormatter.Format(IFormatProvider provider, String format, IList`1 args)
2022-04-02 00:19:59.771 at SmartFormat.Core.Parsing.Parser.ParseFormat(String inputFormat)
2022-04-02 00:19:59.771 at SmartFormat.Pooling.SmartPools.ParsingErrorsPool.get_Instance()
2022-04-02 00:19:59.771 at System.Lazy`1.CreateValue()
2022-04-02 00:19:59.771 --- End of stack trace from previous location ---
2022-04-02 00:19:59.771 at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)

axunonb commented 2 years ago

Sounds like a multi-threading issue (also because you mentioned "heavy load"):

If this is not the case,, please provide your settings and the code snippet where you use the SmartFormatter.

msmart commented 2 years ago

Thanks for this hint! We didnt have SmartSettings.IsThreadSafeMode = true. We'll do some local load testing with this approach and deploy to prod again after confirmation that we can reproduce the error and resolve it with this locally. I'll close this ticket for now and re-open if we are not able to fix it with this approach. Thanks again!

axunonb commented 2 years ago

@msmart We just published release v3.1.0: