Issues Referencing Script Libraries from Other Script Libraries

trueter (21 posts)
July 5, 2019 06:56 AM
Accepted Answer

Hi,

It seems whenever I do an import/export of script libraries from one AdTempus environment to another, I run into issues with script libraries that reference other script libraries.  The errors look something like this when I try to run a job that references a script library:

 

PortPlusLibrary.AppendDateToFileNames - Exception: Could not load file or assembly 'ScriptLibrary.085590cb-61d0-46ed-9751-94fd40023ba6.20190202154754, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. 

 

I can verify that the script library with OID 085590cb-61d0-46ed-9751-94fd40023ba6 does exist in the DB, and that it validates successfully.  How can I troubleshoot this issue?

 

AdTempus Versions:

Product Version: 4.4
Console Version: 4.4.0.0
Client Components Version: 4.4.0.1
Server Version: 4.4.0.17240 (4.4.0.17240) 

 

 

Thanks,

Tim

This topic has an accepted answer. Jump to it.
Bill Staff (599 posts)
July 7, 2019 09:25 AM
Accepted Answer

When you run a script, the adTempus script engine compiles the code into a .NET assembly. If the script references libraries, they are also compiled into assemblies. These assemblies are all cached so that the next time the code is run, it doesn't have to be recompiled. When you modify a script or library, it gets recompiled the next time it's run, and the cache is updated. (The file name you cited contains the OID of the library plus the last modified timestamp of the library.)

What seems to be happening in your case is:

  • You've got a script, Script A, that has been compiled and cached, referencing the PortPlusLibrary library, which has been compiled and cached as a result.
  • You import a new version of the PortPlusLibrary.
  • Some script, Script X, runs that references the library, causing the library to get recompiled and cached with a new timestamp. The script engine then purges the old version of the library from the cache.
  • You run Script A again. Script A has not been modified since the last time it was run, so the script engine doesn't recompile it--it just uses the cached assembly. The cached assembly is compiled to look for the old version of PortPlusLibrary, which no longer exists in the cache, so the script fails.

I don't think it matters that you have a library referencing another library, except that the same problem could be shifted over one step in the process--the script references Library X, which references PortPlusLibrary. In this case the script successfully loads Library X, but Library X is looking for the old PortPlusLibrary and therefore fails.

The bug here is that the script engine should be checking to see if any of the libraries referenced by the script have been updated, and recompile the script in that case. We'll start working on a fix for that.

In the meantime one workaround is to clear the script engine's cache after you do the import. The cache is found under "C:\Users\UserName\AppData\Local\Arcana Development\adTempus\ScriptEngine\Cache", where UserName is the user whose account the job is running under. If you are running script jobs under multiple user accounts, you will need to clear the cache for each user.

You can just delete everything in that folder, but the catch is that you won't be able to do it while the job host (adtempus.jobhost.exe) is running. This process will shut itself down if it hasn't run any scripts in the last 10 minutes or so, or you can kill it through Task Manager if you're sure no scripts are running.

In testing out your issue we found a more serious problem with importing in version 4.6, so don't go updating to 4.6 in the hope that the new version will fix your issue.

trueter (21 posts)
July 8, 2019 09:34 AM
Accepted Answer
Thanks Bill.  For now we'll try purging the cache after each import.  
Bill Staff (599 posts)
July 8, 2019 10:01 AM
Accepted Answer

I was a little wrong on this: it does matter that the library you're modifying is indirectly referenced by the script--that is, I assume, your script references Library X, which references PortPlusLibrary. The Script Engine does correctly handle modification to libraries directly referenced by the script, but it misses libraries referenced by libraries.

If you have a limited number of libraries, another workaround is to open and save the ones that reference PortPlusLibrary. This will update their timestamps, so the Script Engine will recompile any scripts that use them.

 

Bill Staff (599 posts)
July 16, 2019 03:04 PM
Accepted Answer
This problem has been fixed. See article K00000583 for more information. The import problem I mentioned has also been fixed.

Replies are disabled for this topic.