Invalid conversion from type HostIndexedProperty to type Boolean #719
Unanswered
DanielGerlach2
asked this question in
Q&A
Replies: 1 comment
-
|
Hi @DanielGerlach2, We've tested the following with ClearScript 7.5.0 and 7.5.1. The behavior is identical and correct, as far as we can tell: Imports System
Imports Microsoft.ClearScript.Windows
Public Class App
Public Sub New(adminMode As Boolean)
Me.AdminMode = adminMode
End Sub
Public ReadOnly Property AdminMode() As Boolean
End Class
Module Program
Sub Main(args As String())
Using engine As New VBScriptEngine
engine.DisableDynamicBinding = True
engine.AcceptEnumAsUnderlyingType = True
engine.MarshalEnumAsUnderlyingType = True
engine.AddHostObject("App", new App(True))
Console.WriteLine(engine.Evaluate("App.AdminMode"))
End Using
End Sub
End ModuleThis app prints "True" with both ClearScript versions – 7.5.0 without the enum marshaling flags, and 7.5.1 with and without them. Are you doing something differently? Thanks! |
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello ClearScript Team,
The update to ClearScript 7.5.1 resolved several issues regarding its integration into our application. 👍
See here.
However, I have now discovered a new problem 😟
There are properties defined as Booleans.
e.g.
Public ReadOnly Property AdminMode() As BooleanWhen evaluating them via the script engine, I receive the following error message:
ScriptEngine.Evaluate("App.AdminMode")-> Invalid conversion from type HostIndexedProperty to type BooleanThe evaluation of
ScriptEngine.Evaluate("App.AdminMode = True"), however, works as expected.Is there a switch or setting that allows me to change this behavior?
Ideally, only the return value of the property should be evaluated/returned.
Unfortunately, modifying the affected code is not possible, as this can be flexibly utilized and configured by users themselves; consequently, this approach would no longer be manageable or maintainable.
Or is the side effectreferring to related to the
MarshalEnumAsUnderlyingTypeorAcceptEnumAsUnderlyingTypeattributes?best regards
Daniel
Beta Was this translation helpful? Give feedback.
All reactions