I am recently working with one type library requirement. I have created a c# class that will be exposed to COM component. However, when I set a value to an array property I get a compiler error. All the code are placed here.
Looking forward to your expert comments!
(VBA) Compile error:
Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic
C# Com Class
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(_LeafletTestClass))]
[ProgId("Leaflet.WebService.Toolkit.LeafletWS.LeafletTestClass")]
[Guid("364C5E66-4412-48E3-8BD8-7B2BF09E8922")]
public class LeafletTestClass : _LeafletTestClass
{
[ComVisible(true)]
public string[] TestArrayString
{
[return: MarshalAs(UnmanagedType.SafeArray)]
get;
[param: MarshalAs(UnmanagedType.SafeArray)]
set;
}
}
[ComVisible(true)]
[Guid("8C034F6A-1D3F-4DB8-BC99-B73873D8C297")]
public interface _LeafletTestClass
{
[ComVisible(true)]
string[] TestArrayString
{
get;
set;
}
}
VBA Create Object
Sub test()
Dim testClass As LeafletTestClass
Set testClass = New LeafletTestClass
Dim arr(0 To 1) As String
arr(0) = "Test value"
testClass.TestArrayString = arr
End Sub
ClassInterfaceType.None? Any particular reason?