top of page

Fix UnauthorizedScriptingAPIAccessException

As you upgrade your scripts to ESAPI 15.x you may encounter the following exception as soon as your script starts:


VMS.TPS.Common.Model.UnauthorizedScriptingAPIAccessException: Application was not able to execute script '<Your\Script\Path>'. The script '<Your Script (version)>' is not a valid ESAPI script.


This exception happened to me when I tried using the EclipsePlugInRunner (v. 2.0.0) on a script using ESAPI 15.5. It also happened on a stand-alone app that depended on ESAPI 15.5.


The problem seems to happen when an application references an assembly that references ESAPI 15.x but the application itself doesn't use ESAPI directly. It doesn't matter if you reference ESAPI from the application. If nothing in ESAPI is used by the application, then the exception occurs (probably because the compiler optimizes away the reference).


The solution, then, is to make sure you use something from ESAPI (and reference ESAPI) from the main application. For example, you could define the following method:


// Fix UnauthorizedScriptingAPIAccessException
public void DoNothing(PlanSetup plan) { }

This is enough to prevent the compiler from optimizing away the ESAPI reference. Once the reference is included in the application, you won't get the above exception.

Related Posts

See All

Comments


bottom of page