How to solve this problem when we transform a picture?Help me

The formatter threw an exception while trying to deserialize the message: Error while trying to deserialize parameterhttp://tempuri.org/:GetUserPhotoResult. There was an error deserializing the object of type System.Drawing.Bitmap
[339 byte] By [madwww] at [2007-12-24]
# 1
No idea which build you are using - but I suspect that you need to add Bitmap as a known type to your contract.
E.g.:
[DataContract]
[KnownType(typeof (Bitmap))]
public class TecTvEpisode
...

Cheers,
Christian

ChristianWeyer at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2
Also check whether you have set the readerQuotas to an appropriate value. This is necessary as by default the image is sent as an array of bytes.
E.g.

<netTcpBinding>
<binding name="biggerArrayAndUnsecure">
<readerQuotas maxArrayLength="800000" />
</binding>
</netTcpBinding>

Cheers,
Christian
ChristianWeyer at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3

the Exception is :

The formatter threw an exception while trying to deserialize the message: Error while trying to deserialize parameter http://tempuri.org/:GetUserPhotoResult. There was an error deserializing the object of type System.Drawing.Bitmap

And, it is work well in Feb WinFX, now our platform is May WinFX.

It is strange, when we let the PC's NETWORK connection enable, is also work well.

but, it will throw exception when we let the PC's NETWORK connection disabled.

Please help me.. What can we do?

Thanks!

madwww at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 4
Is this the same problem as here
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=580657&SiteID=1
and here
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=580664&SiteID=1
?

If yes, please try not to post several entries re. the same issue, thx.

Anyway did my answer in http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=580664&SiteID=1 help you in any way?

If not, then please post your client and service config here.

Cheers,
Christian

ChristianWeyer at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 5

I am Soryy for the same posts.

That is the config file. it use the HttpBingding. Now only few picture can to transform successful.

<appSettings>
<add key="UserProfileServiceAddress" value="http://localhost:1982/UserProfileService"/>
</appSettings>
<system.serviceModel>
<diagnostics wmiProviderEnabled="true" performanceCountersEnabled="true" />
<services>

<service name="ProjectHelen.Server.UserProfileService">
<endpoint address=""
binding="basicHttpBinding"
contract="ProjectHelen.Server.Contracts.IUserProfileService" />
</service>

</services>
<bindings>

<netTcpBinding>
<binding name="maxMessageSizeTcpBinding"
closeTimeout="00:00:10"
openTimeout="00:00:20"
receiveTimeout="00:00:30"
sendTimeout="00:00:40"
maxConnections="200" >
</binding>
</netTcpBinding>

<customBinding>
<binding name="reliableSessionTcpBinding">
<reliableSession/>
<binaryMessageEncoding/>
<!--<tcpTransport maxBufferSize="10485760"
maxBufferPoolSize="10485760"
maxMessageSize="10485760"/>-->
<tcpTransport />
</binding>
</customBinding>
</bindings>
</system.serviceModel>

madwww at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 6
As already mentioned in the other thread, it looks like you need to adjust thereaderQuotas on your binding.

From the SDK:

Gets or sets constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding. The complexity constraints provide protection from denial of service (DOS) attacks that attempt to use message complexity to tie up endpoint processing resources. Other complexity constraints include items such as a maximum element depth and a maximum length for string content within the message.

<bindings>
<basicHttpBinding>
<binding name="X">
<readerQuotas
maxArrayLength="8888888"/>

</binding>
</basicHttpBinding>
<bindings>

Feel free to choose an appropriate value for your scenario.

Cheers,
Christian
ChristianWeyer at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 7

Thank you, but...

I also add

<basicHttpBinding>
<binding name="maxMessageHttp" maxBufferSize="10485760" maxBufferPoolSize="10485760" maxReceivedMessageSize="10485760">
<readerQuotas maxArrayLength="800000"/>
</binding>
</basicHttpBinding>

But, no effect.

Now, one picture (13k) is transformed successfully, but other picture(one is 5K) can not be successful. May be the problem is not caused by size.

Now, Only the one picture can work well, any other one will be failed.

use the SvcTraceViewer can log the exception, but can not provide some help informations.

Very strange.

madwww at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 8
Hm, really strange.
Can you send over the code to christian.weyer __AT__ thinktecture.com?

Cheers,
Christian

ChristianWeyer at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 9

it is in a large project.

I attempt to separate the key code.

madwww at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 10
I have send a mail to you with a project code
madwww at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 11

Thank you, Now, We solve it.

transform Stream instead of the Bitmap is likely ok!

but, i did not know why..

madwww at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 12

May you show me how do you have change to Stream Object?

I have same problem, bu when tranfer Stream Object instead of Bitmap, the received Stream is unusable, length property thow and exception.

Thanks

DavidRguez at 2007-10-7 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified