thank you for your reply,
In order to get faster, I am trying to achieve the same functionality using C# code.
I encountered two problems when running the code
1. Unable to register component
2. How to get the return value
The following are the code of the powershell and C#, the powershell code can run successfully, But the above problems exist in the C# code.
Any suggestions are welcome, thanks in advance
Can you combine powershell code and C# code and QM code into one file, and test the execution speed of each piece of code?
This is a good example of The QM calling a third-party C# component.
Macro QM Run PS Code
Macro QM Run C# Code
In order to get faster, I am trying to achieve the same functionality using C# code.
I encountered two problems when running the code
1. Unable to register component
2. How to get the return value
The following are the code of the powershell and C#, the powershell code can run successfully, But the above problems exist in the C# code.
Any suggestions are welcome, thanks in advance
Can you combine powershell code and C# code and QM code into one file, and test the execution speed of each piece of code?
This is a good example of The QM calling a third-party C# component.
Macro QM Run PS Code
;Requires 32-bit components Link: http://www.chilkatsoft.com/downloads_DotNet.asp
;Put the dll file in the location C:\Chilkat\ChilkatDotNet47.dll
str code=
;[Reflection.Assembly]::LoadFile("C:\Chilkat\ChilkatDotNet47.dll")
;
;$json = New-Object Chilkat.JsonObject
;
;# The only reason for failure in the following lines of code would be an out-of-memory condition..
;
;# An index value of -1 is used to append at the end.
;$index = -1
;
;$success = $json.AddStringAt(-1, "Title", "Pan's Labyrinth")
;$success = $json.AddStringAt(-1, "Director", "Guillermo del Toro")
;$success = $json.AddStringAt(-1, "Original_Title", "El laberinto del fauno")
;$success = $json.AddIntAt(-1, "Year_Released", 2006)
;
;$json.EmitCompact = $false
;$($json.Emit())
PsCmd3 code "" _s
out _s ;;Can get the return result
Macro QM Run C# Code
;Requires 32-bit components Link: http://www.chilkatsoft.com/downloads_DotNet.asp
;Put the dll file in the location C:\Chilkat\ChilkatDotNet47.dll
RegisterNetComComponent "C:\Chilkat\ChilkatDotNet47.dll" 2|4
CsExec("") ;;How to get the running result
#ret
//C# code
using System;
using Chilkat;
public class Test
{
public string Main()
{
Chilkat.JsonObject json = new Chilkat.JsonObject();
bool success;
// The only reason for failure in the following lines of code would be an out-of-memory condition..
// An index value of -1 is used to append at the end.
int index = -1;
success = json.AddStringAt(-1,"Title","Pan's Labyrinth");
success = json.AddStringAt(-1,"Director","Guillermo del Toro");
success = json.AddStringAt(-1,"Original_Title","El laberinto del fauno");
success = json.AddIntAt(-1,"Year_Released",2006);
json.EmitCompact = false;
//Console.WriteLine(json.Emit());
return json.Emit()
}
}