While evaluating Telerik.Documents.Spreadsheet.Trial (2021.1.118) I've encountered a bug with registering custom functions in .NET 5.
I'm using a console application, and trying to register a couple of functions right at the start of the Main() method. It works like a charm with target framework netcoreapp3.1.
But as soon as I bump the version to net5.0, registering a function throws an exception (I've copied the full stack below).
Perhaps you can guide me what happens? We're currently evaluating on upgrading our license for the latest features, but this thing could be crucial to us, since we need to use .NET 5 for a couple of reasons.
I'm calling them right at the start of the applicaption
public
static
void
Main(
string
[] args)
{
FunctionManager.RegisterFunction(
new
AAA());
FunctionManager.RegisterFunction(
new
BBB());
...
}
Here's the exception stack:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.FunctionManager' threw an exception.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeInitializationException: The type initializer for 'Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.Db' threw an exception.
---> System.ArgumentOutOfRangeException: Index and count must refer to a location within the string. (Parameter 'count')
at System.String.Remove(Int32 startIndex, Int32 count)
at Telerik.Windows.Documents.Spreadsheet.Formatting.FormatHelper.FindAllOccurrences(String value, String part)
at Telerik.Windows.Documents.Spreadsheet.Formatting.FormatHelper.ReplaceSeparators(String formatString, Predicate`1 shouldReplaceWithGroupSeparator, Predicate`1 shouldReplaceWithDecimalSeparator, String newGroupSeparat
or, String newDecimalSeparator)
at Telerik.Windows.Documents.Spreadsheet.Formatting.FormatHelper.ReplaceCultureSpecificSeparatorsWithDefaults(String formatString, Nullable`1 formatStringCategory)
at Telerik.Windows.Documents.Spreadsheet.Model.CellValueFormat..ctor(String formatString, Boolean convertToInvariant, Nullable`1 formatStringCategory)
at Telerik.Windows.Documents.Spreadsheet.Model.CellValueFormat..ctor(String formatString)
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.Db..cctor()
--- End of inner exception stack trace ---
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.Db..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.FunctionManager..cctor()
--- End of inner exception stack trace ---
at Telerik.Windows.Documents.Spreadsheet.Expressions.Functions.FunctionManager.RegisterFunction(FunctionBase function)
at Iface.Oik.ScriptEngine.Program.Main(String[] args) in C:\Users\alexeid\Rider\Iface.Oik.ScriptEngine\src\Program.cs:line 20