473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.SecurityMessagePrope rty'.
at
System.ServiceModel.Security.SecurityMessageProper ty.ThrowIfDisposed()
at
System.ServiceModel.Security.SecurityMessageProper ty.get_ServiceSecurityContext()
at
System.ServiceModel.Dispatcher.SecurityImpersonati onBehavior.GetAndCacheSecurityContext(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.SecurityImpersonati onBehavior.StartImpersonation(MessageRpc&
rpc, IDisposable& impersonationContext, IPrincipal&
originalPrincipal)
at
System.ServiceModel.Dispatcher.DispatchOperationRu ntime.InvokeBegin(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRu ntime.ProcessMessage5(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRu ntime.ProcessMessage4(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRu ntime.ProcessMessage3(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRu ntime.ProcessMessage2(MessageRpc&
rpc)
at
System.ServiceModel.Dispatcher.ImmutableDispatchRu ntime.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

Jun 12 '07 #1
0 1952

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Hogan | last post by:
Hello, I am attempting to send emails using T-SQL (in a SQLServerAgent Job) using the stored procedure sp_SendSMTPMail. I created the stored proc using the following script that I got off a post...
6
by: owen | last post by:
Generally speaking, what does it mean when I see a "button" with red text showing this message instead of the control I've dragged onto the web form in Design View.? (But the page works fine at...
4
by: Altramagnus | last post by:
I have 30 - 40 type of different window. For each type I need about 20 instances of the window. When I try to create them, I get "Error creating window handle" My guess is there is a maximum...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
0
by: Ravi Ambros Wallau | last post by:
Hi: I've created a custom control - a grid that uses Infragistics to display some filters, the grid itself, and some buttons. Well, when using this control directly on WebForm, everything works...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.