[VB.NET] [MWArray] Can't cast MWNumericArray to MWCellArray

조회 수: 2 (최근 30일)
R Sch
R Sch 2013년 8월 6일
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개)

카테고리

Help CenterFile Exchange에서 Deploy to .NET Applications Using MWArray API에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by