Parameter HostItem instead of correct Type #693
-
|
I may have found another problem with the ComVisible setting for projects/assemblies and hope you can help me with a "simple" setting so that this works correctly. I have added a sample project (see below) where the behavior is understandable. Here is a textual description of the processing in the code, so that it may be easier to understand: Please do not question the logic in this example project; it is greatly simplified, but illustrates the problem. Things get really interesting when you change the ComVisible attribute (<Assembly: ComVisible(True)>) in the AssemblyInfo.vb file from True to False. Is there a setting that needs to be configured when initializing the ScriptEngine to ensure the type is passed correctly? |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments
-
|
Hello @DanielGerlach2, Thanks for posting your sample! Unfortunately, it left us confused, as its behavior appears identical regardless of the Are we missing something? Is that not the correct behavior? If it is, how do we reproduce the incorrect behavior? Cheers! |
Beta Was this translation helpful? Give feedback.
-
|
I'm afraid you didn't get the correct version of the example project. The code described is from an older request and doesn't match the example project mentioned above. |
Beta Was this translation helpful? Give feedback.
-
Ah, you're right! Sorry about that! Not sure how it happened 🤣 Anyway, the behavior you're seeing is expected. By exposing the Unfortunately, while
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your explanation. Your proposed solution is understandable and plausible, but not applicable to our situation. We are migrating from MSScriptControl to ClearScript as our scripting component. We would appreciate it if you could provide this accordingly. Have a nice weekend, best regards |
Beta Was this translation helpful? Give feedback.
-
|
Hi @DanielGerlach2,
To do that, we need to understand your scenario better. It's not about questioning your logic but finding a solution that works within your restrictions, makes sense from an API perspective, and provides a permanent fix free of hidden gotchas. To that end, can you tell us why you're using Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Regarding the other inquiries, I've reviewed our current code again. We encountered the following errors/issues:
Since we come from the MSScriptControl world, as mentioned above, some objects are passed via AddHostObject (DirectAccess). Other objects are passed as parameters (by the host) to script functions. (This corresponds to the code in the example project.) Since most of the problems were solved by passing the objects via DirectAccess, we believe it makes sense to also provide a "DirectAccess" option for "passed parameter". |
Beta Was this translation helpful? Give feedback.
-
|
Hi @DanielGerlach2, The problem is that ClearScript has no involvement in script code's communication with Your experience is a good example.
If we understand correctly, there are two issues if you don't use
ClearScript 7.5 includes a fix for the first issue. The reflection binder now supports sparse argument lists. As for the second issue, we suggested a solution here. Is it not practical in your case? Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your reply. You're right that with ClearScript 7.5, functions with missing optional parameters can be used even without DirectAccess. While it would be possible in principle to provide the proposed adapters for enums, this is not feasible in this project due to the associated effort. Internally, Enums are all integral numeric types, which can be directly compared to integer values, at least in vb.net code. e.g. The example shows that assignment as an integer or as an enum is possible; and also that comparison between enum and integer or enum and enum is possible without (compiler) errors. Have a nice weekend, best regards P.S. The main advantage we hope to gain from ClearScript is its 64-bit capability, which we will need for migrating our application to .NET8 (or higher). |
Beta Was this translation helpful? Give feedback.
-
|
Hi @DanielGerlach2, After some experimentation, we believe we can make enum-integer interop work without
Please send your thoughts. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry for the delay, but I was on vacation 😁 Thank you very much, your answer sounds very promising. 👍 Regarding point 1: Regarding point 2: |
Beta Was this translation helpful? Give feedback.
-
|
Excellent! Barring unexpected findings, we'll add the following in the next release:
Unfortunately, we can't give you an ETA for the next release. Hopefully some time before the new year. |
Beta Was this translation helpful? Give feedback.
Excellent! Barring unexpected findings, we'll add the following in the next release:
Unfortunately, we can't give you an ETA for the next release. Hopefully some time before the new year.