Home All Groups Group Topic Archive Search About

Object Type Conversion Error

Author
21 Dec 2006 2:16 PM
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

Author
21 Dec 2006 2:19 PM
Bmack500
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
Author
21 Dec 2006 7:20 PM
Chris Dunaway
Bmack500 wrote:

> 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.
Author
21 Dec 2006 7:53 PM
Bmack500
Oh, I see. I had a similiar section in my code, but I had it wrapped in
a class first.

Thanks!

Chris Dunaway wrote:
Show quoteHide quote
> Bmack500 wrote:
>
> > 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.