How to solve the problem?Help me

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

Answer this question

How to solve the problem?Help me

  • F. Gsell

    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


  • Steve Cagen

    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



  • kwcah

    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!

     


  • Secrets

    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


  • webflier

    I have send a mail to you with a project code
  • Nikhil Doshi

    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>


  • ChopperDavo

    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.

     


  • bio4ema

    As already mentioned in the other thread, it looks like you need to adjust the readerQuotas 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



  • sahady

    Hm, really strange.
    Can you send over the code to christian.weyer __AT__ thinktecture.com

    Cheers,
    Christian


  • DeJaVu1230

    it is in a large project.

    I attempt to separate the key code.


  • Tom Frey

    Thank you, Now, We solve it.

    transform Stream instead of the Bitmap is likely ok!

    but, i did not know why..


  • soanfu

    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


  • How to solve the problem?Help me