У меня есть пользовательский объект, но я не могу передать массив в него. Я вставлю свой код ниже. Массив, который я пытаюсь передать, - это «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.
Остальное работает нормально. Сообщение об ошибке началось только после добавления массива в него.
Спасибо за помощь.
Что такое 'ProxiesObj' на самом деле? Вы использовали отладчик? –
Это объект, исходящий из объекта активной директории "proxyAddresses". Он содержит прокси Exchange –
Что такое _type_, настраиваемый тип или один из фреймворков? Он вообще реализует 'IEnumerable (Of String)'? В противном случае вы не сможете использовать его в 'For .. Every'. –