【发布时间】:2019-06-01 22:12:36
【问题描述】:
我正在使用第 3 部分程序的 COM 接口来获取有关我的功能的信息。 (VS2017 和框架 4.7.2)。
我收到来自 Visual Studio 的错误:以下函数的“Option Strict On 不允许后期绑定”
'x, y, z, al, be, ga. as an array
Protected Friend Shared Function GetComputedBRFPos(ByVal bodyElement As IScrBody, ByVal index As Integer) As Array
Return bodyElement.getComputedBRFPos(p_index:=index)
End Function
它在第 3 部分工具中有一个文档,我也在编写描述。
VARIANTList getComputedBRFPos ()
获取当前 BRF 位置,如果不存在求解器,则创建一个隐式求解器。数组元素:x、y、z、al、be、ga。
举个例子,我正在使用另一个正在使用的函数,但下面的函数没有后期绑定错误。
Protected Friend Shared Function Get_sb_node_pos(ByVal bodyElement As IScrBody, ByVal childIndex As Integer) As Array
Return bodyElement.get_sb_node_pos(p_childIndex:=childIndex)
End Function
这是文档中的描述。
VARIANTList get_sb_node_pos (int childIndex)
获取所有元素 sb_node_pos 作为一个数组。
我认为它会导致 bodyElement.getComputedBRFPos(p_index:=index) "index" 值,但我不知道确切的问题是什么以及如何实现。
【问题讨论】:
-
我认为这是因为除非显式强制转换,否则您无法将数组的内容拆箱。基本上,编译器在返回数组之前并不知道数组里面有什么。
-
@AlessandroMandelli 是的,也许是因为我得到了一个数组列表,但没有在函数处定义索引,然后像 bodyElement.getComputedBRFPos() 一样使用,之后就不可能了主函数如 GetComputedBRFPos(Body)(i) ?
-
你可能需要指定数组的类型——如果你返回一个包含字符串的数组,我认为你的函数声明的结尾应该——不要引用我的话,比如
Friend Shared Function (your parameters here) As String()而不是简单的As Array
标签: vb.net late-binding