Iterate through oraclehomes.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
mrbig
Posts: 9
Joined: Fri 31 Oct 2008 23:01

Iterate through oraclehomes.

Post by mrbig » Fri 15 Jan 2010 08:36

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

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 15 Jan 2010 14:48

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)

mrbig
Posts: 9
Joined: Fri 31 Oct 2008 23:01

Post by mrbig » Sun 17 Jan 2010 10:00

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

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 18 Jan 2010 13:59

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.

Post Reply