iT邦幫忙

0

無法將vb.net List(of Class) 參數傳遞到 COM+ c# List<Class> 參數

  • 分享至 

  • xImage

我將 vb.net List(of Class) 參數傳遞到 C# COM+ List 參數 但是出現以下錯誤

SUPERMANDao方法引動過程失敗,因為 'Public Function DATAmultiFILE(DATA As String(), TFILE As System.Collections.Generic.List(Of MultiFile), ByRef SQL As String, ByRef CHECKOUT As String) As String' 無法使用這些引數呼叫:\r\n 與參數 'TFILE' 對應的引數無法從 'List(Of MultiFile)' 轉換為 'List(Of MultiFile)'。"

vb.net 程式碼 SUPERMANDao.vb :

Public Function DATAmultiFILE(ByVal PARA As MultiData, ByVal TFILE As List(Of MultiFile)) As DATASAVEOUT

        Dim Obj As Object = Nothing
        Dim TOUT As New DATASAVEOUT
        Dim RESULT As String = ""
        Dim DATA(17) As String
        Dim SQL As String = ""
        Dim CHECKOUT As String = ""
        Try
            DATA(0) = PARA.KIND
            DATA(1) = PARA.NO
            DATA(2) = PARA.PROD
            DATA(3) = PARA.MODEL
            DATA(4) = PARA.MODID
            DATA(5) = PARA.TITLE
            DATA(6) = PARA.CONTENT
            DATA(7) = PARA.STATUS
            DATA(8) = PARA.REPLY
            DATA(9) = PARA.MODU
            DATA(10) = PARA.MDATE
            DATA(11) = ""
            DATA(12) = ""
            DATA(13) = ""
            DATA(14) = ""
            DATA(15) = ""
            DATA(16) = ""


            Obj = CreateObject("PVTASUPERMAN.CVTASUPERMAN2") 
            RESULT = Obj.DATAmultiFILE(DATA, TFILE, SQL, CHECKOUT) '我在此傳遞 List(of Class)
            TOUT.MSG = "DATAANDFILE" + ",SQL=" + SQL + ",CHECKOUT" + CHECKOUT
            TOUT.STATE = RESULT

        Catch ex As Exception
            TOUT.STATE += "FAIL_SUPERMANDao" + SQL + CHECKOUT
            TOUT.MSG += "FAIL_SUPERMANDao" + ex.Message + SQL + CHECKOUT
            ' Finally
            ' System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj)
        End Try

        Return TOUT

    End Function    

我傳遞 Obj.DATAmultiFILE post the parameter string() DATA 成功

但是傳遞 TFILE As List(Of MultiFile) 失敗

vb.net 程式碼 MultiFile Class :

Public Class MultiFile
    Public Property FILENAME() As String
        Get
            Return M_FILENAME
        End Get
        Set
            M_FILENAME = Value
        End Set
    End Property
    Private M_FILENAME As String
    Public Property Extension() As String
        Get
            Return M_Extension
        End Get
        Set
            M_Extension = Value
        End Set
    End Property
    Private M_Extension As String
    Public Property FULLPATH() As String
        Get
            Return M_FULLPATH
        End Get
        Set
            M_FULLPATH = Value
        End Set
    End Property
    Private M_FULLPATH As String
    Public Property BUFFER() As Byte()
        Get
            Return M_BUFFER
        End Get
        Set
            M_BUFFER = Value
        End Set
    End Property
    Private M_BUFFER As Byte()
End Class

C# com+ PVTASUPERMAN.CVTASUPERMAN2 DATAmultiFILE 程式碼:

public string DATAmultiFILE(string[] DATA, List<MultiFile> TFILE, ref string SQL, ref string CHECKOUT)
        {
string RC = "";
            return RC;
        }

string[] DATA, ref string SQL, ref string CHECKOUT傳遞成功.

List TFILE 傳遞失敗.

C# com+ PVTASUPERMAN.CVTASUPERMAN2 MultiFile class 程式碼:

        public class MultiFile
        {
            public string FILENAME { get; set; }
            public string Extension { get; set; }
            public string FULLPATH { get; set; }
            public byte[] BUFFER { get; set; }
        }

傳遞後出現錯誤訊息 :
SUPERMANDao方法引動過程失敗,因為 'Public Function DATAmultiFILE(DATA As String(), TFILE As System.Collections.Generic.List(Of MultiFile), ByRef SQL As String, ByRef CHECKOUT As String) As String' 無法使用這些引數呼叫:\r\n 與參數 'TFILE' 對應的引數無法從 'List(Of MultiFile)' 轉換為 'List(Of MultiFile)'。

請問我如何將 vb.net List(of Class) 參數傳遞到 COM+ List 參數? 謝謝各位大大!

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
rofellos
iT邦新手 2 級 ‧ 2022-02-07 16:14:04

我猜是vb的MultiFile跟c#的MultiFile根本是不同東西,就算名字內容一樣,你丟入C#的物件的MultiFile,要創個c#的MultiFile填值再丟進去

我要發表回答

立即登入回答