[VB.NET] [MWArray] Can't cast MWNumericArray to MWCellArray
2 views (last 30 days)
Show older comments
I'm currently working on a project to reroute an existing .NET tool from an 'old' DLL-deploy to the .NET DLL-deploy. So far, so good. I am calling the DLL and it initializes. However, it seems you need to feed the newer DLL-type with the MWArray data-types. I am using a 2011a DLL in 32-bits.
So I switched from the old 'Object-type' to designated MWArrays. I have 5 arrays, 4 of which are exclusively numeric in the data it needs to hold. The fifth, has a small problem, because it will have to contain string-types and numerics (doubles). For this, I have read I need to use the MWCellArray, but it does not work, and I keep getting the following error message;
Unable to cast object of type 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' to type 'MathWorks.MATLAB.NET.Arrays.MWCellArray
This is the calling code;
Dim dr As DataRow
For rowIndex As Integer = 0 To dTable.Rows.Count - 1
dr = dTable.Rows(rowIndex)
newArray(rowIndex, 0) = CDbl(dr(0))
For columnIndex As Integer = startkolom + 1 To dTable.Columns.Count - 1
If dr(columnIndex) Is Nothing OrElse _
IsDBNull(dr(columnIndex)) OrElse _
dr(columnIndex).ToString.Length = 0 OrElse _
dr(columnIndex).ToString = "#N/A" Then
newArray(rowIndex, columnIndex - startkolom) = Double.NaN
Else
If IsNumeric(dr(columnIndex)) Then
newArray(rowIndex, columnIndex - startkolom) = CDbl(dr(columnIndex))
Else
newArray(rowIndex, columnIndex - startkolom) = dr(columnIndex)
End If
End If
Next
Next
0 Comments
Answers (0)
See Also
Categories
Find more on Deploy to .NET Applications Using MWArray API in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!