EDN Admin
Well-known member
Hi,<br/> <br/> Im trying to pass enum array from VBA to my .NET library. However, it is throwing exception that "Specified array is not of expected type". How do I achieve it?<br/> In my .NET library, I have declared the parameter to pass by reference, which is how it is expected to pass array from COM to .NET. Still for Enums, it is not working. Kindly tell me what should I do to overcome this. Here is my sample calls.<br/> <br/> IN .NET, I have declared an Enum and then trying to use it in function.<br/> <br/> [ComVisible(true)]<br/> public enum DataType<br/> { <br/> Integer,<br/> Double,<br/> String,<br/> DateTime<br/> }<br/> <br/> [ComVisible(true)]<br/> public class UserInterfaceControls<br/> {<br/> public void Test(ref DataType[] colTypes)<br/> {<br/> MessageBox.Show(colTypes.ToString());<br/> }<br/> }<br/> <br/> From VBA, Im trying to call like<br/> <br/> Dim arrType(1) As DataType<br/> arrType(0) = DataType_String<br/> arrType(1) = DataType_Integer<br/> <br/> obj = instance of UserInterfaceControls<br/> <br/> obj.Test arrType.<br/> <br/> This call is throwing exception that "Specified array was not of the expected types".<br/> <br/> Kindly give me some resolution for this problem.<br/> <br/> Thanks,<br/> Sushant M.
View the full article
View the full article