Error with DateTime.Ticks when creating new package
Hello When trying to create a new package on Business Central On Premise (dk version) I do get an error:
Processing of message 'al/createPackage' failed with error: 'Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks' Details: System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
- AL Langauge: 2.1.79379
- Business Central: 13.0.27183.0
I was trying to find any instances of DateTime variables, fields etc. but these do not cause the problem. Did any of you encounter a similar error?
Mat
Hi @MatDDev,
Do you have some more information on the issue? Was there a StackTrace with the error? Can you share a zip file here with the needed files to reproduce it.
Processing of message 'al/createPackage' failed with error: 'Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks'
Details:
System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
at System.DateTime..ctor(Int64 ticks)
at Microsoft.Dynamics.Nav.CodeAnalysis.Utilities.DateTimeUtilities.CSideDateToDateTime(Int32 date) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Utilities\DateTimeUtilities.cs:line 60
at Microsoft.Dynamics.Nav.CodeAnalysis.Utilities.DateTimeUtilities.FormatCSideDate(Int32 date, String formatString) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Utilities\DateTimeUtilities.cs:line 130
at Microsoft.Dynamics.Nav.CodeAnalysis.Utilities.ObjectDisplay.FormatDate(Int32 date) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Utilities\ObjectDisplay.cs:line 39
at Microsoft.Dynamics.Nav.CodeAnalysis.BoundLiteralPropertyValue.get_ValueText() in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\BoundTree\BoundPropertyValues\BoundLiteralPropertyValue.cs:line 31
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourcePropertySymbol.get_ValueText() in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourcePropertySymbol.cs:line 208
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ConvertProperties(Symbol symbolWithProperties) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:line 682
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.<>c.<ConvertTableFields>b__20_1(FieldSymbol f) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:line 410
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ConvertTableFields(ApplicationObjectTypeSymbol table) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:line 405
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ConvertTableBase(ApplicationObjectTypeSymbol tableBase) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:line 383
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ConvertTables(IEnumerable`1 tables) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:line 353
at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ConvertModuleToSerializableSymbolModel(IModuleSymbol module) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:line 24
at Microsoft.Dynamics.Nav.CodeAnalysis.Packaging.PackageModuleOutputter.AddSymbolReference(IPackageWriter writer, IModuleSymbol moduleSymbol) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Packaging\PackageModuleOutputter.cs:line 651
at Microsoft.Dynamics.Nav.CodeAnalysis.Packaging.PackageModuleOutputter.FinalizeModule() in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Packaging\PackageModuleOutputter.cs:line 603
at Microsoft.Dynamics.Nav.CodeAnalysis.Compilation.WriteToOutput(ModuleOutputter outputter, ModuleBuilder moduleBuilder, ModuleSymbol compiledModuleSymbol) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\Compilation.cs:line 854
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.PackageTheModule(Compilation compilation, CompilerTextWriter consoleOutput, CancellationToken cancellationToken, ErrorLogger errorLogger, AnalyzerDriver analyzerDriver) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 596
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCore(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 435
at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.Run(CompilerTextWriter consoleOutput, CancellationToken cancellationToken) in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 313
at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.CreatePackageRequestHandler.<HandleAsync>d__4.MoveNext() in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\CreatePackageRequestHandler.cs:line 47
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Dynamics.Nav.EditorServices.Protocol.MessageProtocol.RequestHandlerBase`1.<HandleAsync>d__10.MoveNext() in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\MessageProtocol\RequestHandlerBase.cs:line 45
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.<Process>d__6.MoveNext() in C:\a\42\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:line 59
Unfortunately I cannot share the files. If it's not directly related to DateTime variables or fields, what the error might be related to? According to the error, it crashes when trying to use DateTime constructor with invalid arguments, but I cannot find a case like that in the code.
So, I've found what was wrong with this and maybe this could be useful to some of you. There was a MinValue in one of the Date fields in the table (NAV 5.01) set to:

and was successfully converted by txt2al to:

But when trying to build a package this particular property was causing a problem. There was no problem with MaxValue. Maybe there should be the error that this value is not valid for this property?
Thanks @MatDDev for locating the issue.
The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 28496.
If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo
For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://blogs.msdn.microsoft.com/freddyk/2018/04/16/which-docker-image-is-the-right-for-you/