0

I am trying to run this script:

$dll = Add-Type -Path \\machineX\Folder\\AL.Scripting.dll
New-Object AL.Scripting.BsmScriptObject

When running on PS 5.1 everything runs fine, but when ran on PW 7 I get:

System.AggregateException: One or more errors occurred. 
(Error importing Scripting Object DLL.Exception calling ".ctor" with "0" argument(s):
 "Method not found: 'Void System.AppDomainSetup.set_ApplicationBase(System.String)'.")

I am trying to make this PW command result accessible through .NET Core API, but it seems it's to be impossible, because .NET Core solutions can use only PowerShell 6.0-7.0 versions. Maybe is there any workarounds?

  • 1
    PowerShell 5.1 runs on the .NET Framework 4.0 runtime, PowerShell 7 uses the newer .NET Core runtime. If `AL.Scripting.dll` was compiled for .NET Framework it indeed won't work with the .NET Core runtime. You'll need to re-compile it. If `AL.Scripting` is vendor-supplied, ask the vendor if they have a newer version of the library – Mathias R. Jessen Jul 29 '21 at 10:23
  • @MathiasR.Jessen Maybe it's possible to launch process of PW 5.1 in .Net Core application? Since PW 5.1 is installed anyways – Edvardas Alaburda Jul 29 '21 at 10:38
  • Absolutely! Nothing stops you from doing `powershell -File C:\scriptWithAlScriptingRoutine.ps1` from `pwsh` – Mathias R. Jessen Jul 29 '21 at 10:53

0 Answers0