Can t use GetProperty, error: Index was outside the bounds of the array.

Can t use GetProperty, error: Index was outside the bounds of the array.

Old forum URL: forums.lhotka.net/forums/t/7680.aspx


tutus posted on Thursday, September 24, 2009

Hi,

I try to use the code bellow:

Public Shared ReadOnly NBR_DOORSProperty As PropertyInfo(Of Integer) = RegisterProperty(GetType(Integer), New PropertyInfo(Of Integer)("NBR_DOORS", "NBR_DOORS", -1))
        Public Property NBR_DOORS() As Nullable(Of Integer)
            Get
                Return GetProperty(NBR_DOORSProperty)
             End Get
            Set(ByVal value As Nullable(Of Integer))
                SetProperty(NBR_DOORSProperty, value, -1)
            End Set
        End Property

But in runtime I get the error: Index was outside the bounds of the array. in the line of code:

Return GetProperty(NBR_DOORSProperty)

Any idea pls, I m using CSLA 3.5 and VS2008

 

Fintanv replied on Thursday, September 24, 2009

tutus:

Hi,

I try to use the code bellow:

Public Shared ReadOnly NBR_DOORSProperty As PropertyInfo(Of Integer) = RegisterProperty(GetType(Integer), New PropertyInfo(Of Integer)("NBR_DOORS", "NBR_DOORS", -1))
        Public Property NBR_DOORS() As Nullable(Of Integer)
            Get
                Return GetProperty(NBR_DOORSProperty)
             End Get
            Set(ByVal value As Nullable(Of Integer))
                SetProperty(NBR_DOORSProperty, value, -1)
            End Set
        End Property

But in runtime I get the error: Index was outside the bounds of the array. in the line of code:

Return GetProperty(NBR_DOORSProperty)

Any idea pls, I m using CSLA 3.5 and VS2008

 

 

<Disclaimer>I am not a vb.net guru. </Disclaimer>

However shouldn't your property declaration be something like:

Private Shared NBR_DOORSProperty As PropertyInfo(Of Integer) = RegisterProperty(Of Integer)(GetType(YOUR CLASS NAME), New PropertyInfo(Of Integer)("NBR_DOORS", "NBR_DOORS", -1))

ajj3085 replied on Thursday, September 24, 2009

You're correct. He's registering the property, saying it belongs to the type Int32, which clearly isn't correct.

The normal use of RegisterProperty, you shouldn't be specifying the type argument at all... let Csla figure it out for you.

tutus replied on Friday, September 25, 2009

'The normal use of RegisterProperty, you shouldn't be specifying the type argument at all... let Csla figure it out for you. "

 

It's weird, buit it would not let me use the overload with only New PropertyInfo(0 ... It tells me there is no overload that takes only thoses arguements. it seems that the CSLA version I m using (3.5) expects too arguements at least for the method: RegisterProperty  . I m not sure what I m doing wrong :(

ajj3085 replied on Friday, September 25, 2009

Are you inheriting Csla.BusinessBase[T]? Might be worthwhile to upgrade to 3.7.

tutus replied on Friday, October 02, 2009

ajj3085:
Are you inheriting Csla.BusinessBase[T]? Might be worthwhile to upgrade to 3.7.

I appologize for the delay. I inherit from BusinessBase. We are using 3.5.0.0 version of CSLA. I don t think it s an option to upgrade the dll at this stage of the project just for this bug. We re pretty much in deployement phase, and this is a huge project :)

Thanks a lot for any clues about my issue :)

ajj3085 replied on Friday, October 02, 2009

Well, there are two classes called BusinessBase, one is generic one is not. They are:

Csla.BusinessBase( Of T ) and
Csla.Core.BusinessBase

So my earlier question was are you inheriting from the first one? It doesn't sound like you are, because that's the one that has all the overloads of RegisterProperty which don't need a type parameter. So if you're not, you should be in 99% of all cases.

Copyright (c) Marimer LLC