While running a PowerShell Job in JAMS, users may receive the following error when trying to run a Job that accesses a .NET 2.0 feature that is not able to run on .NET 4.0. The error message would be like the following:
System.IO.FileLoadException Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
If users are not using any features of the .NET 4.0 framework, there is a option that needs to be configured in the PowerShell Execution Method in JAMS in order to force the Job to run in .NET 2.0. In order to make this configuration change:
- Go to the JAMS GUI Client Interface and click on the Execution Method shortcut in the shortcut bar on the left.
- Find the PowerShell Execution Method and double-click it to open the Properties.
- On the Execution tab of the Properties add V2 to the Options text-box.
Note: Execution Method options must be comma separated
- Click Save/Close (The Green Check-Mark) to Save the changes to the Execution Method.
- Once these changes have been made, users should now be able to run the Job successfully.
If using any features of the .NET 4.0 Framework, setting the Options in the Execution Method to force those Jobs to run in .NET 2.0 will not work. In this case, users will need to add the useLegacyV2RuntimeActivationPolicy attribute to a .config file on the JAMS Scheduler (%InstallRoot%:\Program Files\MVPSI\JAMS\Scheduler\). For Routine Execution Methods such as PowerShell, we look in the Options field for V2. We then use:
V2 and x86 - JAMSHostV232.exe.config
V2 - JAMSHostV2.exe.config
x86 - JAMSHost32.exe.config
Neither - JAMSHost.exe.config
Once users have determined the correct .config file, add the following at the top of the configuration area of this file:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup>
**Note: If running job(s) on an agent then only change the JAMSHost.exe.config file found in C:\Program Files\MVPSI\JAMS\Agent. Restart of the JAMSAgent service will not be required.