我创建了一个自定义对象,但似乎无法将数组传递给它。我将把我的代码粘贴到下面。我尝试传递的数组是"UserProxies“数组。
我的对象:
Public Class obj
Public isPrimary As String
Public AccountName As String
Public DisplayName As String
Public mail As String
Public DistinguishName As String
Public HomeDirectory As String
Public EmployeeId As String
Public Description As String
Public HomeDrive As String
Public ScriptPath As String
Public telephoneNumber As String
Public mobile As String
Public streetAddress As String
Public City As String
Public Province As String
Public Country As String
Public postalCode As String
Public company As String
Public EmployeeTitle As String
Public profilePath As String
Public homeMDB As String
Public legacyExchangeDN As String
Public TargetAddress As String
Public Enabled As String
Public IsAccountLockedOut As String
Public BadLogonCount As String
Public LastBadPasswordAttempt As String
Public LastLogon As String
Public LastPasswordSet As String
Public ActiveSync As String
Public UserProxies() As String
Sub New(isprimary As String, AccountName As String, DisplayName As String, mail As String, DistinguishName As String, HomeDirectory As String, EmployeeId As String, Description As String, HomeDrive As String, ScriptPath As String, telephoneNumber As String, mobile As String, streetAddress As String, City As String, Province As String, Country As String, postalCode As String, company As String, EmployeeTitle As String, profilePath As String, homeMDB As String, legacyExchangeDN As String, TargetAddress As String, Enabled As String, IsAccountLockedOut As String, BadLogonCount As String, LastBadPasswordAttempt As String, LastLogon As String, LastPasswordSet As String, ActiveSync As String, UserProxies() As String)
Me.isPrimary = isprimary
Me.AccountName = AccountName
Me.DisplayName = DisplayName
Me.mail = mail
Me.DistinguishName = DistinguishName
Me.HomeDirectory = HomeDirectory
Me.EmployeeId = EmployeeId
Me.Description = Description
Me.HomeDrive = HomeDrive
Me.ScriptPath = ScriptPath
Me.telephoneNumber = telephoneNumber
Me.mobile = mobile
Me.streetAddress = streetAddress
Me.City = City
Me.Province = Province
Me.Country = Country
Me.postalCode = postalCode
Me.company = company
Me.EmployeeTitle = EmployeeTitle
Me.profilePath = profilePath
Me.homeMDB = homeMDB
Me.legacyExchangeDN = legacyExchangeDN
Me.TargetAddress = TargetAddress
Me.Enabled = Enabled
Me.IsAccountLockedOut = IsAccountLockedOut
Me.BadLogonCount = BadLogonCount
Me.LastBadPasswordAttempt = LastBadPasswordAttempt
Me.LastLogon = LastLogon
Me.LastPasswordSet = LastPasswordSet
Me.ActiveSync = ActiveSync
Me.UserProxies = UserProxies
End Sub
End Class我把它填满了:
Public Shared UserProxies() As String 'The Public part is normal
If UserDirectory.Properties("proxyAddresses").Value IsNot Nothing Then
Dim ProxiesObj As Object = UserDirectory.Properties("proxyAddresses").Value 'Proxy to put into object first
Dim x As Integer = 0
For Each Item As String In ProxiesObj
ReDim Preserve UserProxies(x)
UserProxies(x) = Item
x = x + 1
Next
End If
UserObject.add(New obj(PrimaryAccount, AccountName, DisplayName, mail, DistinguishName, HomeDirectory, EmployeeId, Description, HomeDrive, ScriptPath, telephoneNumber, mobile, streetAddress, City, Province, Country, postalCode, company, EmployeeTitle, profilePath, homeMDB, legacyExchangeDN, TargetAddress, Enabled, IsAccountLockedOut, BadLogonCount, LastBadPasswordAttempt, LastLogon, LastPasswordSet, ActiveSync, UserProxies))我在运行时收到错误消息:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.其余的都运行得很好。只有在我将数组添加到其中时,错误消息才开始显示。
谢谢你的帮助。
发布于 2015-07-14 21:30:36
因为我不被允许评论这个问题。(仅12个代表) ;-)
问题是什么时候出现这个异常,尝试用一个try catch块来包围这个异常,或者做进一步的调试,也许问题不是将该数组作为数组本身的创建传递给对象。
https://stackoverflow.com/questions/31407951
复制相似问题