System.StackOverflowException

Discussion in 'ASP .Net' started by Simon Harris, May 8, 2005.

  1. Simon Harris

    Simon Harris Guest

    Hi All,

    When I set the property of title in my class (Shown below) I get a
    "Exception of type System.StackOverflowException was thrown." error message.

    I'm guessing I got some sort of horrible loop going on, where did I go
    wrong?

    Thanks,
    Simon.

    Private pTitleAs String

    Public Property Title() As String
    Get
    Return pStrTitle
    End Get
    Set(ByVal Value As String)
    Title = pStrTitle
    End Set
    End Property
     
    Simon Harris, May 8, 2005
    #1
    1. Advertising

  2. Simon Harris

    Simon Harris Guest

    Never mind - Realised my properties were in a right old mess :)


    "Simon Harris" <> wrote in message
    news:...
    > Hi All,
    >
    > When I set the property of title in my class (Shown below) I get a
    > "Exception of type System.StackOverflowException was thrown." error
    > message.
    >
    > I'm guessing I got some sort of horrible loop going on, where did I go
    > wrong?
    >
    > Thanks,
    > Simon.
    >
    > Private pTitleAs String
    >
    > Public Property Title() As String
    > Get
    > Return pStrTitle
    > End Get
    > Set(ByVal Value As String)
    > Title = pStrTitle
    > End Set
    > End Property
    >



    --
    I am using the free version of SPAMfighter for private users.
    It has removed 2175 spam emails to date.
    Paying users do not have this message in their emails.
    Try www.SPAMfighter.com for free now!
     
    Simon Harris, May 8, 2005
    #2
    1. Advertising

  3. Simon Harris

    Sherif Guest

    Hello
    Change
    Title = pStrTitle
    to
    pStrTitle = Value

    Best regards,
    Sherif

    "Simon Harris" <> wrote in message
    news:...
    > Hi All,
    >
    > When I set the property of title in my class (Shown below) I get a
    > "Exception of type System.StackOverflowException was thrown." error
    > message.
    >
    > I'm guessing I got some sort of horrible loop going on, where did I go
    > wrong?
    >
    > Thanks,
    > Simon.
    >
    > Private pTitleAs String
    >
    > Public Property Title() As String
    > Get
    > Return pStrTitle
    > End Get
    > Set(ByVal Value As String)
    > Title = pStrTitle
    > End Set
    > End Property
    >
     
    Sherif, May 8, 2005
    #3
  4. you're setting the title of the string with pstrTitle, but the set action
    itself calls the property again recursively. The solution provided by sherif
    will fix the problem, i just thought you wanted to know the why.

    --
    Regards,
    Alvin Bruney - ASP.NET MVP

    [Shameless Author Plug]
    The Microsoft Office Web Components Black Book with .NET
    Now available @ www.lulu.com/owc, Amazon.com etc
    "Simon Harris" <> wrote in message
    news:...
    > Hi All,
    >
    > When I set the property of title in my class (Shown below) I get a
    > "Exception of type System.StackOverflowException was thrown." error
    > message.
    >
    > I'm guessing I got some sort of horrible loop going on, where did I go
    > wrong?
    >
    > Thanks,
    > Simon.
    >
    > Private pTitleAs String
    >
    > Public Property Title() As String
    > Get
    > Return pStrTitle
    > End Get
    > Set(ByVal Value As String)
    > Title = pStrTitle
    > End Set
    > End Property
    >
     
    Alvin Bruney [MVP - ASP.NET], May 9, 2005
    #4
  5. ....but thanks for the replies (I posted my reply before yours appeared)
     
    Web Team @ Borough of Poole, May 11, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.StackOverflowException: Exception of type System.StackOverf

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,193
    =?Utf-8?B?UHN5Y2hv?=
    Oct 8, 2004
  2. Lars-Erik Aabech
    Replies:
    8
    Views:
    763
    Steven Cheng[MSFT]
    Apr 29, 2005
  3. =?Utf-8?B?RGFuaWxv?=

    Problem with DllImport StackOverFlowException

    =?Utf-8?B?RGFuaWxv?=, Apr 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    605
    Scott Allen
    Apr 22, 2005
  4. HyVong
    Replies:
    1
    Views:
    639
    Karl Seguin
    Nov 25, 2005
  5. niama
    Replies:
    2
    Views:
    134
    niama
    Mar 9, 2005
Loading...

Share This Page