2017-02-22 78 views
0

在下面的方法,我想一個動態成員添加到的expando對象,但它拋出一個異常:未找到擴展對象添加動態成員到ExpandoObject

公共成員

Private Sub GetAckValues() 
    Try 
     Dim ack_duration As String = String.Empty 
     Dim ack_by_user_fkid As String = String.Empty 
     Dim ack_time As String = String.Empty 
     ack_duration = txtdefaultack.Text 
     ack_by_user_fkid = Convert.ToString(Session("user_code")) 
     Dim Ack_Detail As Object = New ExpandoObject() 
     Ack_Detail.ack_duration = ack_duration 
     Ack_Detail.ack_by_user_fkid = ack_by_user_fkid 
     receiptObject.StatusObject = Ack_Detail 
    Catch ex As Exception 
     logger.Error("Enter JobRequest form done by :" & LoggedinUserId, ex) 
    End Try 
End Sub 

回答

1

應該這樣:

Ack_Detail.ack_duration = Ack_Detail.ack_duration 

實際上是這樣的:

Ack_Detail.ack_duration = ack_duration 
+0

是的但我不會添加一個成員它顯示異常 –