Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Project compilation error from generate_code function

alby177
2019-05-14
2020-10-08
  • alby177 - 2019-05-14

    Running the attached python script for building one CODESYS project which includes a visualization manager and at least a visualization, launched using the command line as:

    "C:\Program Files (x86)\3S CODESYS\CODESYS\Common\CODESYS.exe" --profile="CODESYS V3.5 SP10 Patch 5" --runscript="BuildCodesys.py" --noUI
    

    The following error is obtained:

    Build: Error: C0: Internal error:System.ArgumentOutOfRangeException: Length cannot be less than zero.
    Parameter name: length
       at System.String.Substring(Int32 startIndex, Int32 length)
       at _3S.CoDeSys.VisualObject.Utilities.GetGlobalTextListFilePath(String stFile, Boolean bCheckCompilerVersion, Boolean bUseEnvironmentVariable)
       at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiationObject.DetermineTextListPaths(String& stTextListPath, String& stTextListPathRelative, String& stTextListFileNameWithoutDirectory)
       at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiationObject.CreateTextListBody(Boolean bRegister)
       at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiationObject.get_InitCode()
       at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiateImagePoolsAndTextlists(DeclarationHelper declDest, List`1 alTypes, List`1 initCodes, List`1 exitCodes, Boolean bBeforCompile, VisualConstraintCheckerCache cache, IAvailableTargetConstraintsProvider2 provider, INamespacesMappingTable optNamespacesTable)
       at _3S.CoDeSys.VisualObject.VisualManagerObject.FillBeforeCompileLanguageModel(LanguageModelMixture lmmixture, ILibraryIdentifiers idents, Int64 lNecessaryProfileId, Boolean bForIntegratedVisu)
       at _3S.CoDeSys.VisualObject.VisualManagerObject.GetStructuredLanguageModel(ILanguageModelBuilder lmbuilder)
       at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.PutLanguageModel(ILanguageModelProvider lanmodprov, Boolean bShowSyntaxErrors, Boolean forceCompleteLanguageModel)
       at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.PutLanguageModel(ILanguageModelProvider lanmodprov, Boolean bShowSyntaxErrors)
       at _3S.CoDeSys.VisualObject.VisualObjectEventWatcher.OnLanguageModelMgr_BeforeCompile(Object sender, CompileEventArgs e)
       at _3S.CoDeSys.Core.LanguageModel.CompileEventHandler.Invoke(Object sender, CompileEventArgs e)
       at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.OnBeforeCompile(CompileEventArgs e)
       at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.RaiseAndCheckBeforeCompile(Guid guidApplication, IMessageCategory cmc)
       at _3S.CoDeSys.LanguageModelManager.Compiler35100.Compiler.(_IPreCompileContext , Guid , Boolean , Boolean , Boolean , Boolean& , _ICompileContext& , _ICompileContext& , IProgressCallback , Boolean , Boolean )
       at _3S.CoDeSys.LanguageModelManager.Compiler35100.Compiler.(Guid , Boolean , Boolean , Boolean , IOnlineChangeDetails& , IMessage[]& , IMessage[]& )
    Build: Text: C0: Build complete -- 1 errors, 0 warnings : no download possible!
    List[Guid]([<System.Guid object at 0x000000000000006C [194b48a9-ab51-43ae-b9a9-51d3edaaddf3]>, <System.Guid object at 0x000000000000006D [97f48d64-a2a3-4856-b640-75c046e37ea9]>])
    Array[str](('------ Build started: Application: Device.Application -------', 'Internal error:System.ArgumentOutOfRangeException: Length cannot be less than zero.\r\nParameter name: length\r\n   at System.String.Substring(Int32 startIndex, Int32 length)\r\n   at _3S.CoDeSys.VisualObject.Utilities.GetGlobalTextListFilePath(String stFile, Boolean bCheckCompilerVersion, Boolean bUseEnvironmentVariable)\r\n   at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiationObject.DetermineTextListPaths(String& stTextListPath, String& stTextListPathRelative, String& stTextListFileNameWithoutDirectory)\r\n   at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiationObject.CreateTextListBody(Boolean bRegister)\r\n   at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiationObject.get_InitCode()\r\n   at _3S.CoDeSys.VisualObject.VisualManagerObject.InstantiateImagePoolsAndTextlists(DeclarationHelper declDest, List`1 alTypes, List`1 initCodes, List`1 exitCodes, Boolean bBeforCompile, VisualConstraintCheckerCache cache, IAvailableTargetConstraintsProvider2 provider, INamespacesMappingTable optNamespacesTable)\r\n   at _3S.CoDeSys.VisualObject.VisualManagerObject.FillBeforeCompileLanguageModel(LanguageModelMixture lmmixture, ILibraryIdentifiers idents, Int64 lNecessaryProfileId, Boolean bForIntegratedVisu)\r\n   at _3S.CoDeSys.VisualObject.VisualManagerObject.GetStructuredLanguageModel(ILanguageModelBuilder lmbuilder)\r\n   at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.PutLanguageModel(ILanguageModelProvider lanmodprov, Boolean bShowSyntaxErrors, Boolean forceCompleteLanguageModel)\r\n   at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.PutLanguageModel(ILanguageModelProvider lanmodprov, Boolean bShowSyntaxErrors)\r\n   at _3S.CoDeSys.VisualObject.VisualObjectEventWatcher.OnLanguageModelMgr_BeforeCompile(Object sender, CompileEventArgs e)\r\n   at _3S.CoDeSys.Core.LanguageModel.CompileEventHandler.Invoke(Object sender, CompileEventArgs e)\r\n   at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.OnBeforeCompile(CompileEventArgs e)\r\n   at _3S.CoDeSys.LanguageModelManager.LanguageModelManager.RaiseAndCheckBeforeCompile(Guid guidApplication, IMessageCategory cmc)\r\n   at _3S.CoDeSys.LanguageModelManager.Compiler35100.Compiler.\x01(_IPreCompileContext \x02, Guid \x03, Boolean \x04, Boolean \x05, Boolean \x06, Boolean& \x07, _ICompileContext& \x08, _ICompileContext& \x0e, IProgressCallback \x0f, Boolean \x10, Boolean \x11)\r\n   at _3S.CoDeSys.LanguageModelManager.Compiler35100.Compiler.\x01(Guid \x02, Boolean \x03, Boolean \x04, Boolean \x05, IOnlineChangeDetails& \x06, IMessage[]& \x07, IMessage[]& \x08)', 'Build complete -- 1 errors, 0 warnings : no download possible!'))
    

    Using the same command within the IDE environment doesn't return any error and the download on the target is allowed.

    Is there a way to solve the error?
    Thank you

    Environment:
    CODESYS version: 3.5 SP 10 patch 5
    MS Windows 7 64 bit

    BuildCodesys.py [1.31 KiB]

     
  • maoravni - 2020-10-08

    Hi,

    I know it's been a long time, but did you manage to solve the internal error issue?

    I'm having the same error here.

     

Log in to post a comment.