Object Type Conversion Error

  • Thread starter Thread starter Bmack500
  • Start date Start date
B

Bmack500

Hello all, and thank you in advance!

The below code keeps giving me the error:
Conversion from type 'Object()' to type 'Integer' is not valid.

Do I need to do some casting or somethign?

All I'm doing is passing an object which contains a structure,
Dictionary(type Integer, string) and a
system.directoryservices.searchresultcollection.

Dim ControlThreadVals As Object = New Object() {svrInfo,
dcDict, svrResults}
Try
'******Here's where I get the error: *********************
controllerThread = New System.Threading.Thread(AddressOf
ControlThread, ControlThreadVals)
'********************************************************
controllerThread.IsBackground = True
controllerThread.Start()

While controllerThread.IsAlive
Application.DoEvents()
End While

Catch ex As Exception
Dim strErr As String = ex.Message
Debugger.Break()
End Try
 
Ooops, sorry! The while loop is actually outside the try catch block,
as below.


Dim ControlThreadVals As Object = New Object() {svrInfo,
dcDict, svrResults}
Try
'******Here's where I get the error: *********************
controllerThread = New System.Threading.Thread(AddressOf
ControlThread, ControlThreadVals)
'********************************************************
controllerThread.IsBackground = True
controllerThread.Start()

Catch ex As Exception
Dim strErr As String = ex.Message
Debugger.Break()
End Try

While controllerThread.IsAlive
Application.DoEvents()
End While
 
Bmack500 said:
Dim ControlThreadVals As Object = New Object() {svrInfo,
dcDict, svrResults}
Try
'******Here's where I get the error: *********************
controllerThread = New System.Threading.Thread(AddressOf
ControlThread, ControlThreadVals)
'********************************************************

Well, according to the docs, none of the constructors for the Thread
class takes an object array as a parameter. Since ControlThreadVals is
an object array and not an integer, it produces the exception you are
seeing.
 
Oh, I see. I had a similiar section in my code, but I had it wrapped in
a class first.

Thanks!
 
Back
Top