Bad CRC32 in GZIP stream

你离开我真会死。 提交于 2019-12-24 11:24:07

问题


I am using DevForce 2010 and Silverlight 4.

When saving entities that contain large amount of binary data, I get this error:

Unhandled Error in Silverlight Application The remote server returned an error: NotFound.

When debuging the application I see these errors:

Unhandled Error in Silverlight Application Insufficient memory to continue the execution of the program.

Bad CRC32 in GZIP stream.

I found this thread on Ideablades forum that discusses the problem: http://www.ideablade.com/forum/forum_posts.asp?TID=3361&PN=1&title=bad-crc32-in-gzip-stream

Is this a problem on the server or client?

Is this a problem that has been resolved in any new version of DevForce 2010?

My server has 4 GB memory. Would increasing the memory resolve the problem?

Or what would be the right solution?


回答1:


Yes, the OnEndpointCreated overrides on both client and server are where you should add the customization. You can add the following to remove GZIP from the binding:

public override void OnEndpointCreated(System.ServiceModel.Description.ServiceEndpoint endpoint)
{
    if (endpoint.Binding is CustomBinding)
    {
        var binding = endpoint.Binding as CustomBinding;
        var elements = binding.CreateBindingElements();

        // Swap out existing (GZIP) message encoding for binary
        var encoding = elements.Find<MessageEncodingBindingElement>();
        if (encoding != null)
        {
            elements.Remove(encoding);

            encoding = new BinaryMessageEncodingBindingElement();
            elements.Insert(0, encoding);
            endpoint.Binding = new CustomBinding(elements);
        }
    }
}

DevForce will find your classes if they're in an assembly probed on the client/server.

This will turn off compression for everything from your DevForce client to the EntityServer, so may be a bit heavy-handed. You can turn on IIS compression to compress data sent to the client to help.




回答2:


There haven't been any changes to GZIP processing since the 6.1.7 release of DevForce 2010. That thread still contains the best information of how to work around the problem: 1) modify the save logic or your entity definition to reduce the amount of data saved; 2) turn off use of GZIP; or 3) write a custom message encoder with another compression library.




回答3:


Thank you Kim Johnson,

I have looked at the samples and I feel uncomfortable adding those config files and maybe breaking something that works fine today.

If I go the code-way, will I be ably to switch off GZIP and still retain the rest of the default settings for DevForce?

I guess the code below is what I should go for?

If I save these classes on the client and server, will DevForce automatically find these classes?

//Client

using System.ServiceModel.Channels;
using IdeaBlade.Core.Wcf.Extensions;

public class ProxyEvents  : IdeaBlade.EntityModel.ServiceProxyEvents {

  public override void OnEndpointCreated(System.ServiceModel.Description.ServiceEndpoint endpoint) {
    base.OnEndpointCreated(endpoint);
    // My client code turning GZIP off comes here?
  }
  public override void OnFactoryCreated(System.ServiceModel.ChannelFactory factory) {
    base.OnFactoryCreated(factory);
  }
}

//Server
using System.ServiceModel.Channels;
using IdeaBlade.Core.Wcf.Extensions;

public class ServiceEvents : IdeaBlade.EntityModel.Server.ServiceHostEvents {

  public override void OnEndpointCreated(System.ServiceModel.Description.ServiceEndpoint endpoint) {
    base.OnEndpointCreated(endpoint);
    // My server code turning GZIP off comes here?
  }
  public override void OnServiceHostCreated(System.ServiceModel.ServiceHost host) {
    base.OnServiceHostCreated(host);
  }
}


来源:https://stackoverflow.com/questions/23868149/bad-crc32-in-gzip-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!