Results 1 to 5 of 5

Thread: new class with inherits, some properties gone?!

  1. #1

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Post new class with inherits, some properties gone?!

    Code:
    Public Class Form1
    
        Public Class SearchTask
            Inherits List(Of String)
            ' Fields
            Public SearchTerm As String
            Public SoundEx As String
            Public AdminSettingsHash As Integer
    
        End Class
    
        Public St As New SearchTask
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            St.AdminSettingsHash = 302
            St.Add("test1")
            St.Add("test2")
            St.Add("test3")
            St.Add("test4")
            St.Add("test5")
            MsgBox(St.AdminSettingsHash)
        End Sub
    
    End Class
    Why is it that if you run this, a message box appears stating '302', but if you check the debugger for the 'St' no property called 'AdminSettingsHash' is listed. Also if you serialize the class, the list of strings are saved, but not the SearchTerm, SoundEx or AdminsettingsHash.

    Thanks in advance!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: new class with inherits, some properties gone?!

    The class isn't marked serializable, so that could have an issue, depending on what type of serialization you are using. There are plenty of properties that don't show up in the debugger. I'm pretty sure that you can set them that way (I think I did, once), but in your case, it appears that not showing up is all they are doing, since you report that the code is working (other than the serialization). You don't have them as properties anyways. They are member variables as you have it written.

    What do you mean by "check the debugger"? That could mean a couple different things, and the specific one you are using may be important.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Re: new class with inherits, some properties gone?!

    To make it more clear;

    Code:
    Imports System.IO
    Imports System.Xml.Serialization
    
    
    Public Class Form1
    
        Public Class SearchTask
            Inherits List(Of String)
            ' Fields
            Public SearchTerm As String
            Public SoundEx As String
            Public AdminSettingsHash As Integer
    
        End Class
    
        Public St As New SearchTask
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            St.AdminSettingsHash = 302
            St.SoundEx = "0123"
            St.SearchTerm = "yadda"
            St.Add("test1")
            St.Add("test2")
            St.Add("test3")
    
            Dim string_writer As New StringWriter()
            Dim serializer As New XmlSerializer(GetType(SearchTask))
            serializer.Serialize(string_writer, St)
            MsgBox(string_writer.ToString)
    
        End Sub
    
    End Class
    Why don't I see 'AdminSettingsHash' etc, in the XML string?

  4. #4

    Thread Starter
    Addicted Member Lectere's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    222

    Re: new class with inherits, some properties gone?!

    If I remove the 'inherits' from the class, the other options do show up.

    Of course I could 'code around it' somehow, but I've rather understand why this is happening. Also, when I debug, I don't see 'adminsettingshash' with the 'st' instance.

  5. #5
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: new class with inherits, some properties gone?!

    You can give the fields an System.ComponentModel.EditorBrowsable attribute to make them show up in Visual Studio Intellisense:

    Code:
    	<System.ComponentModel.EditorBrowsable(EditorBrowsableState.Always)> _
     Public TestField As Object
    The EditorBrowsableState argument determines if the field or property will show up in the Intellisense Common tab or Advanced tab. It wouldn't surprise me if something similar applies to using the Serializable attribute, but I don't have much experience with that. BB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width