Home > Archive > ASP .NET > December 2006 > Image data in profile: 28 bytes unaccounted for?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Image data in profile: 28 bytes unaccounted for?
|
|
|
| Hi,
I'm using the ASP.NET 2.0 profile system to keep an image of members of my
website "MyWebsite".
Initially, I've created the property in the web.config like:
<add name="Photo" serializeAs="Binary" type="System.Byte[]" >
Doing so, the binary data was saved in the "PropertyValuesBinary" column in
"aspnet_profile".
Now I need to query the "aspnet_profile" table from another website,
"MyOtherWebsite", and I want to read the image-data.
Therefore, I've altered the profile property like:
<add name="Photo" serializeAs="Binary" type="System.Byte[]"
customProviderData="image"/>
Now the binary data gets saved in a new column "Photo" in "aspnet_profile".
In "MyWebsite", the image data is correctly read by Profile.Photo.
In "MyOtherWebsite", the image data is queried by SQL (DataTable) but when I
read the column "Photo" from "aspnet_profile" the binary data is 28 bytes
longer than the binary data returned by Profile.Photo.
How do I get rid of those extra 28 bytes?
Kind Regards,
Roel
| |
| bruce barker 2006-12-20, 7:08 pm |
| profile stores a serialized byte array, not just the data. use the
binary deserializer to read the column.
-- bruce (sqlwork.com)
Roel wrote:
> Hi,
>
> I'm using the ASP.NET 2.0 profile system to keep an image of members of my
> website "MyWebsite".
>
> Initially, I've created the property in the web.config like:
> <add name="Photo" serializeAs="Binary" type="System.Byte[]" >
>
> Doing so, the binary data was saved in the "PropertyValuesBinary" column in
> "aspnet_profile".
>
> Now I need to query the "aspnet_profile" table from another website,
> "MyOtherWebsite", and I want to read the image-data.
>
> Therefore, I've altered the profile property like:
> <add name="Photo" serializeAs="Binary" type="System.Byte[]"
> customProviderData="image"/>
>
> Now the binary data gets saved in a new column "Photo" in "aspnet_profile".
>
> In "MyWebsite", the image data is correctly read by Profile.Photo.
> In "MyOtherWebsite", the image data is queried by SQL (DataTable) but when I
> read the column "Photo" from "aspnet_profile" the binary data is 28 bytes
> longer than the binary data returned by Profile.Photo.
>
> How do I get rid of those extra 28 bytes?
>
> Kind Regards,
> Roel
>
>
| |
|
| Thanx Bruce!
I've used this code to deserialize the byte array:
private byte[] DeserializeImage(byte[] image)
{
byte[] buf = image;
MemoryStream ms = new MemoryStream();
ms.Write(buf, 0, buf.Length);
ms.S (0, 0);
BinaryFormatter b = new BinaryFormatter();
return (byte[])b.Deserialize(ms);
}
This does the trick!
Kind Regards,
Roel
"bruce barker" <nospam@nospam.com> wrote in message
news:%23NwXeBFJHHA.3676@TK2MSFTNGP03.phx.gbl...[color=darkred]
> profile stores a serialized byte array, not just the data. use the binary
> deserializer to read the column.
>
> -- bruce (sqlwork.com)
>
> Roel wrote:
|
|
|
|
|