Page 1 of 1

Iterate through oraclehomes.

Posted: Fri 15 Jan 2010 08:36
by mrbig
Hi

Im trying to get all avaiable Oracle homes on the computer. I use the following code:

Code: Select all

For i As Integer = 0 To OracleConnection.Homes.Count - 1
   Console.WriteLine(OracleConnection.Homes.Item(i).Name.ToString)
Next
I am getting the following exception in the console.writeline:
  • System.NullReferenceException was unhandled
    Message="Object reference not set to an instance of an object."


If I'm using the immediate window to get the name, it is working perfectly

Code: Select all

?OracleConnection.Homes.Item(0).Name
"Ora9"
If I'm using the name to get the OracleHome class it is also working as it should.

Code: Select all

Dim H As String = OracleConnection.Homes.Item("Ora9").Name.ToString
The only problem seems to be when trying to iterate trough the homes.
Can anyone help me solve this issue ?

Thanks !
/Klaus

Posted: Fri 15 Jan 2010 14:48
by StanislavK
The integer variable is automatically converted to a string to match the Item() method signature.

Please try casting the collection to the IList interface:

Code: Select all

Dim il As IList = OracleConnection.Homes
Console.WriteLine(il.Item(i).Name)

Posted: Sun 17 Jan 2010 10:00
by mrbig
Hi

The IList haven't got the Name proberty. And when casting I have the same problem.

I have solved the problem using an enumerator and casting to an OracleHome class. So my problem is solved...

But still I cannot see why the iteration using item(i) shoulden't work. As I see it, the problem must be related to a bug in the Devart assembly.

Best regards,
/Klaus

Posted: Mon 18 Jan 2010 13:59
by StanislavK
IList has the Item property with the integer argument: il.Item(i). It returns the OracleHome object, which, in turn, has the Name property.

The Item(A_0 as Integer) method is an internal method of the OracleHomeCollection class, it should not be accessible, except by casting to the IList interface. Intellisense showing this method might be an Intellisense error.