GZip Encoder Sample

Switch View :
ScriptFree
.NET Framework Samples
GZip Encoder Sample

The GZip Encoder sample demonstrates how to create a Windows Communication Foundation (WCF) extensibility point. This sample, which is available only in Visual C#, creates an encoder channel that uses the System.IO.Compression.GZipStream class to compress outgoing WCF messages.

For information about using the samples, see the following topics:

Download sample

To build and deploy the sample using Visual Studio

  1. Open Windows Explorer and navigate to the the IndigoGzipSample directory.

  2. Double-click the IndigoGzipSample.sln file to open it in Visual Studio.

  3. Press F5 to compile and run the sample. You will be prompted to select whether to deploy the sample to a Pocket PC or to a Pocket PC emulator.

Requirements

Microsoft Visual Studio 2008 must be installed with the smart device development components. This includes the .NET Compact Framework version 3.5, which is required to build and run the sample. To compile the sample using msbuild.exe, see How to: Compile at the Command Prompt.

You must also install the Windows Mobile 6 Software Development Kit (SDK) Refresh.

To install the .NET Compact Framework on the device, see How to: Install the .NET Compact Framework.

See Also

Other Resources

Community Content

Sidon
GetProperty<T> bug
Change GetProperty<T> method to enable custom (not default) soap version and addressing (same as used in messageEncoderBindingElement): $0 $0$0 $0
public override T GetProperty<T>(BindingContext context)
{
if (context == null)
throw new ArgumentNullException("context");

if (typeof(T) == typeof(MessageVersion))
return (T)(object)this.MessageVersion;

return context.GetInnerProperty<T>();
}
$0
$0$0 $0

Bryan Dougherty
Additional Using Clauses
I know this is kind of old, but I thought I'd point out something that is relevant if you use this for a device.  It looks like some additional "using" clauses should be used to avoid potentially out of memory exceptions.


//Helper method to compress an array of bytes
static ArraySegment<byte> CompressBuffer(ArraySegment<byte> buffer, BufferManager bufferManager, int messageOffset)
{
using (MemoryStream memoryStream = new MemoryStream())
{
...

//Helper method to decompress an array of bytes
static ArraySegment<byte> DecompressBuffer(ArraySegment<byte> buffer, BufferManager bufferManager)
{
using (MemoryStream memoryStream = new MemoryStream(buffer.Array, buffer.Offset, buffer.Count - buffer.Offset))
{
using (MemoryStream decompressedStream = new MemoryStream())
{
...