Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Powershell code failed to run
#5
CsExec  is rarely useful. Start from menu File / New / Templates / Scripting / "Scripting C#, call any functions". Delete unused examples in the code. Add some references if need. Don't need RegisterNetComComponent.

Simplified template:
Macro Scripting C#, call any functions4
Code:
Copy      Help
;create variable that manages compiled C# code
CsScript x

;optionally set some options
;x.SetOptions("debugConfig=true[]references=System.Data;System.XML")

;compile code after #ret
x.AddCode("")

;call static function
str R=x.Call("Class1.TestFunction" "test" 5)
out R


#ret
//C# code
using System;

public class Class1
{
public static string TestFunction(string s, int i)
{
,Console.Write(s); Console.Write(i); //display in QM output
,return "result";
}
}


Messages In This Thread
Powershell code failed to run - by win - 06-15-2019, 12:03 AM
RE: Powershell code failed to run - by win - 06-17-2019, 02:26 PM
RE: Powershell code failed to run - by Gintaras - 06-17-2019, 03:31 PM
RE: Powershell code failed to run - by win - 06-17-2019, 10:51 PM
RE: Powershell code failed to run - by Gintaras - 06-18-2019, 04:45 AM
RE: Powershell code failed to run - by win - 06-18-2019, 07:05 AM
RE: Powershell code failed to run - by Gintaras - 06-18-2019, 07:11 AM
RE: Powershell code failed to run - by win - 06-18-2019, 08:17 AM
RE: Powershell code failed to run - by Kevin - 06-20-2019, 04:44 AM
RE: Powershell code failed to run - by win - 06-20-2019, 05:30 AM
RE: Powershell code failed to run - by Kevin - 06-20-2019, 11:54 AM
RE: Powershell code failed to run - by win - 06-20-2019, 12:50 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)