VBScriptEngine - Use of complex objects as function parameters #626
DanielGerlach2
started this conversation in
General
Replies: 2 comments
-
Hello @DanielGerlach2, We've tried to replicate your scenario based on your description, but we're unable to reproduce any issues. Here's our test program: Public Class Session
End Class
Public Module App
Sub Import(ActSession As Session, Table As String, Data As String)
Console.WriteLine("In Import: '{0}' '{1}' '{2}'", ActSession, Table, Data)
End Sub
End Module
Module Program
Sub Main()
Using ScriptEngine As New VBScriptEngine()
ScriptEngine.AddHostType(GetType(App))
ScriptEngine.AddHostObject("ActSession", New Session)
ScriptEngine.Evaluate("App.Import(ActSession, ""Table"", ""1;2;3;4"")")
End Using
End Sub
End Module Output:
We omitted the Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
-
I tried to break the problem down to an example project, but the transfer works correctly there. I'll try again in the next few days to get it reproducible. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Certain objects are passed to the script control so that they are available and can be used in scripting.
e.g.
ScriptEngine.AddHostObject("ActSession", HostItemFlags.GlobalMembers + HostItemFlags.DirectAccess, ActiveSession)
ActiveSessio has its own type “Session”.
I can access the hosted object via script code and, among other things, access properties, etc.
e.g.
Sub Main
MsgBox(ActSession.TimeStamd)
...
End Sub
However, if I now use the item as a parameter to call a function, I get the following error:
Class does not support automation.
e.g.
Sub Main
App.Import(ActSession, "Table", "1;2;3;4")
...
End Sub
Definition
Sub Import(ActSession as Session, Table as String, Data as String)
If I change the definition to Sub Import(ActSession as Object, Table as String, Data as String) i got the following error on the first access of the parameter.
ClearScript.HostItem cannot be converted to Session
Beta Was this translation helpful? Give feedback.
All reactions