我有一个用vb.net编写的VB6程序的winforms控件。该控件动态添加到VB6控件控件集合中。VB6 Controls集合接受哪些类需要哪些属性?
Set ctrlVB6 = Controls.Add("NETNamespace.SelVB6", "SelNet")
如果.NET类(SelVB6
)拥有所有必要的属性Add方法返回VB6控制包装和控制是可见的。否则,Add方法不会返回任何内容,并且控件在VB6中不可用。
.net类源自System.Windows.Forms.UserControl
,幸运的是它具有所有必需的属性。 .net类用ClassInterface
属性修饰以保证COM可用的属性。
<ClassInterface(ClassInterfaceType.AutoDual)>
Public Class SelVB6
一切正常,但不是System.Windows.Forms.UserControl
所有属性是COM可见的和大量的警告在VS2010中产生。为了摆脱警告我需要知道哪些属性是必要的,定义一个接口并使用ClassInterfaceType.None
。
注
我不允许使用Interop Forms Toolkit。
我知道我可以列出控制属性Control Properties in Visual Basic 6。
警告例如:
Type library exporter warning processing 'NETNamespace.SelVB6.PreProcessControlMessage(#0)'. Warning: Non COM visible value type 'System.Windows.Forms.PreProcessControlState' is being referenced either from the type currently being exported or from one of its base types. Microsoft.Common.targets
它不仅仅是使其成为控件的属性,它来自Control类之一。修复你的属性没有显示出来,警告取决于实际的警告是什么。 – Deanna 2012-03-28 15:51:47
我认为比vb6 over com不会评估.net继承。我添加了警告示例。 – IvanH 2012-04-03 08:44:13
这些警告是正常的,大多数.NET对象不暴露给COM,只有那些需要真正实现正确的接口。 – Deanna 2012-04-03 10:02:36