RE: Serialization Issues and bloated objects

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Sagi,

Are you referring to the default profile provider that is using SqlExpress
as the database store? If this is the case, based on my test, the saved
personal information using profile provider will be all contained in one
table aspnet_Profile and there's only one record for one user.

Here's my test steps:

1) Create following classes:

namespace myns
{
[Serializable]
public class Member
{
private string _name;

public string Name
{
get { return _name; }
set { _name = value; }
}
private int _age;

public int Age
{
get { return _age; }
set { _age = value; }
}

private Policies _policies;

public Policies Policies
{
get { return _policies; }
set { _policies = value; }
}

}

[Serializable]
public class Policy
{
private int _id;

public int Id
{
get { return _id; }
set { _id = value; }
}
private string _name;

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

public Policy()
{
}

public Policy(int id, string name)
{
_id = id;
_name = name;
}
}

[Serializable]
public class Policies : List<Policy>
{
}
}


2) Edit web.config to support profile:

<profile>
<properties>
<add name="Name" type="string"/>
<add name="Member" type="myns.Member"/>
</properties>
</profile>

3) In Default.aspx.cs

if (string.IsNullOrEmpty(Profile.Name))
{
Profile.Name = "Test";
}

if (Profile.Member.Policies == null)
{
Profile.Member.Age = 1;
Profile.Member.Name = "Name";
Profile.Member.Policies = new Policies();
Profile.Member.Policies.Add(new Policy(1, "n1"));
Profile.Member.Policies.Add(new Policy(2, "n2"));
}

4) Open App_Data\AspNetDb.mdf, view table aspnet_Profile's data. It only
contains one record for the user. The field PropertyNames has following
content: "Name:S:0:4:Member:S:4:365:" while there're other two fields used
to store the serialized value:

Test<?xml version="1.0" encoding="utf-16"?>
<Member xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<Name>Name</Name>
<Age>1</Age>
<Policies>
<Policy>
<Id>1</Id>
<Name>n1</Name>
</Policy>
<Policy>
<Id>2</Id>
<Name>n2</Name>
</Policy>
</Policies>
</Member>


I think you may referring to other profile provider. Please let me know
your usage scenario. Thanks.


Sincerely,
Walter Wang (wawang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • Re: Serialization Issues and bloated objects
    ... Are you referring to the default profile provider that is using SqlExpress ... private Policies _policies; ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework)
  • Re: [fw-wiz] httport 3snf
    ... >>> that, it's a monitoring and enforcement issue, not a firewall issue. ... > level of commitment to policy enforcement in general. ... > policy, then it's more than likely time to either switch policies, ... with a list of IPs for HP support. ...
    (Firewall-Wizards)
  • Re: Public School was a waste of my time (Re: When even a Republican can see it....)
    ... "Things were worse with Thatcher's policies than they would have been ... was--perhaps even because it was more laissez-faire. ... I really do struggle with how a person can support such measures if they've ... And it sounds as though the economy itself is pretty rigid. ...
    (rec.arts.sf.fandom)
  • Re: "Even if torture works."
    ... >>>The implicit claim made here is that one cannot support a government in ... >> support over several years for Bush/Blair's foreign policy adventures. ... >> I'm aware that he doesn't support Blair on all policies... ... >invasion of Iraq. ...
    (uk.politics.misc)
  • RE: CS0433: The type ProfileCommon exists in both
    ... Using the default provider still works fine, it's just the custom profile ... I built the first custom profile provider form this example: ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.aspnet)