Image data in profile: 28 bytes unaccounted for?

R

Roel

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
 
B

bruce barker

profile stores a serialized byte array, not just the data. use the
binary deserializer to read the column.

-- bruce (sqlwork.com)
 
R

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.Seek(0, 0);

BinaryFormatter b = new BinaryFormatter();

return (byte[])b.Deserialize(ms);

}

This does the trick!

Kind Regards,
Roel

bruce barker said:
profile stores a serialized byte array, not just the data. use the binary
deserializer to read the column.

-- bruce (sqlwork.com)
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top