RE: WebPart Personalization Blob Deserialize Error



Hi Tom,

From your description, you're writing your custom code to load binary data
from ASP.NET webpart personalization database and deserialize againstit,
however,you're encountering some error on it , correct?

Based on my understanding, it is only when you developing a custom
personalization provider or customize the existing one will you need to
deal with the underlying binary data blob's load & store. So are you
developing your custom webpart personalization provider?

If you're customizing the default SQL personalization provider or also use
the same database, you can have a look at the built-in provider's code
implementation on how to retrieve the binary blob from database. Here is
the code I picked from reflector (of the SqlPersonalizationProvider class)

==================================
private byte[] LoadPersonalizationBlob(SqlConnection connection, string
path, string userName)
{
SqlCommand command;
if (userName != null)
{
command = new
SqlCommand("dbo.aspnet_PersonalizationPerUser_GetPageSettings", connection);
}
else
{
command = new
SqlCommand("dbo.aspnet_PersonalizationAllUsers_GetPageSettings",
connection);
}
this.SetCommandTypeAndTimeout(command);
command.Parameters.Add(this.CreateParameter("@ApplicationName",
SqlDbType.NVarChar, this.ApplicationName));
command.Parameters.Add(this.CreateParameter("@Path",
SqlDbType.NVarChar, path));
if (userName != null)
{
command.Parameters.Add(this.CreateParameter("@UserName",
SqlDbType.NVarChar, userName));
command.Parameters.Add(this.CreateParameter("@CurrentTimeUtc",
SqlDbType.DateTime, DateTime.UtcNow));
}
SqlDataReader reader = null;
try
{
reader = command.ExecuteReader(CommandBehavior.SingleRow);
if (reader.Read())
{
int length = (int) reader.GetBytes(0, (long) 0, null, 0, 0);
byte[] buffer = new byte[length];
reader.GetBytes(0, (long) 0, buffer, 0, length);
return buffer;
}
}
finally
{
if (reader != null)
{
reader.Close();
}
}
return null;
}
=========================================

Also, here are some other reference on building custom personalization
provider:

http://msdn2.microsoft.com/en-US/library/aa479037.aspx

http://msdn.microsoft.com/msdnmag/issues/05/09/WebParts/

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



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: Access 2007 Ribbons
    ... It sets database options, menus, etc. the way that I ... your custom ribbon UI. ... Microsoft Online Community Support ... or a Microsoft Support Engineer within 1 business day is acceptable. ...
    (microsoft.public.access.forms)
  • RE: ViewState vs. Database
    ... records in ASP.NET page's viewstate and query them in every request, ... Using custom display controls. ... recommend you query the data from database in every request where you need ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.general)
  • Re: Trying to import csv file into user defined form
    ... You may find one of our options of interest - both have custom form support ... properties area for the contact database and also set this database to ... How do I get the correct fields to show for the mapping part of the ...
    (microsoft.public.outlook.contacts)
  • Database Driven Pages
    ... I can achieve this when each page is identical - e.g. contains my custom ... text/html control. ... If (database says this page contains xyz control) ... web part to allow the user 'personalization' of the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Database Driven Pages
    ... I can achieve this when each page is identical - e.g. contains my custom ... text/html control. ... If (database says this page contains xyz control) ... web part to allow the user 'personalization' of the ...
    (microsoft.public.dotnet.framework.aspnet)

Loading