Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Error in WCF IEndpoingBehavior when creating a new Message.

 
 
Old 06-12-2007   #1 (permalink)
ronscottlangham@yahoo.com


 
 

Error in WCF IEndpoingBehavior when creating a new Message.

I am working on a custom WCF EndpoingBehavior that will modify the
messages coming in and out of my Service. I am having an error
related to the modification of the message in the
IEndpointBehavior.AfterReceiveRequest(ref Message request,...) method.

In the method that creates a new message, I have something similar
to ...

/// xmlReader defined with new modified content....
/// 'message' is the original message...

Message newMsg = Message.CreateMessage( message.Version,
null, xmlReader );

// Preserve the headers of the original message
newMsg.Headers.CopyHeadersFrom( message );

foreach (string propertyKey in message.Properties.Keys)
newMsg.Properties.Add(propertyKey, message.Properties[propertyKey]);

// Close the original message and return new message
message.Close( );

return newMsg;

This is similar to other code that I have seen on the Internet related
to creating a new message from an existing one. This code ran fine
when under the XP ASP.NET Development server, but when run on Windows
2003 Server (basicHttpBinding, HTTPS, Authentication) I immediately
get an error on the server side after the AfterReceiveRequest method
completes and processing the message. I get the following error...

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.ServiceModel.Security.SecurityMessageProperty'.
at
System.ServiceModel.Security.SecurityMessageProperty.ThrowIfDisposed()
at
System.ServiceModel.Security.SecurityMessageProperty.get_ServiceSecurityContext()
at
System.ServiceModel.Dispatcher.SecurityImpersonationBehavior.GetAndCacheSecurityContext(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.SecurityImpersonationBehavior.StartImpersonation(MessageRpc&
rpc, IDisposable& impersonationContext, IPrincipal&
originalPrincipal)
at
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)

I see where there was a similar bug in .NET before it was officially
release and supposedly fixed,

http://connect.microsoft.com/wcf/fee...dbackID=202762

Apparently, something in the new message or in the processing still
keeps a reference to the original Message and throws an error if it is
closed. If I remove the message.Close() then things work ok.

Any ideas on how to properly create a new Message?

What is the downside if I do not close the original message?

Thanks,
Ron


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Format tab not available when creating a new message Vista mail
Problem Creating New Message Vista mail
Windows Mail minimizes after creating a new message Vista mail
Slowness of creating or replying to a message Vista mail
Error Message in Creating Recovery Discs Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46