Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

User objects in application settings?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Grant Schenck - 12 Jun 2007 01:47 GMT
This seems like is should be straight forward but I'm just not getting it.

I have a very simple class (see below) which I think should be XML
serializable.  I have this class defined in my simple form app's namespace.
Now I want to add an instance of this class to my Application Settings.  So,
I go to Project | Properties | Settings tab and while I can add settings of
various system types I can't seem to add one of type "Foo".  I tried
Browse... but while it shows various system types, it doesn't show my class.

How the heck do I create a setting of type "Foo"???

Once I've got that figured out, how do I create an list of "Foo"s that can
be saved in my settings?

BTW, I use this as an example.  I realize that if all I wanted to store was
a string there are simpler built in types.

Thanks!
Grant Schenck

// -----------------
public class Foo
{
   Foo() {}

   public string Name
  {
     get { return m_strName; }
     set { m_strName = value; }
  }

   private string m_strName;
}
Grant Schenck - 12 Jun 2007 13:52 GMT
Any ideas???

Thanks,

Grant Schenck

> This seems like is should be straight forward but I'm just not getting it.
>
[quoted text clipped - 30 lines]
>    private string m_strName;
> }
Peter Duniho - 12 Jun 2007 18:08 GMT
>> I have a very simple class (see below) which I think should be XML
>> serializable.  I have this class defined in my simple form app's
>> namespace. Now I want to add an instance of this class to my Application
>> Settings.
>
> Any ideas???

Well, since no one who actually knows the answer stepped up, I'll tell you  
what I do know:

If your object is serializable, you can save it in your settings.

To make an object serializable, you add the "[Serializable]" property just  
before the class.  I haven't had a need to do this sort of thing yet, but  
my understanding is that if all the members are already serializable, and  
you don't want any special handling for any of the members, then that's  
all you need to do in order to make the whole class serializable.

It seems to me that those two pieces of information together should  
address your question.

If not, well...I did warn you that I don't actually know the answer.  :)

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.