DCSIMG

 Subscribe in a reader

This message cannot support the operation because it has been copied - Guy kolbis
Tuesday, March 18, 2008 9:22 AM kolbis

This message cannot support the operation because it has been copied

This is an error message I got when I extended WCF with a client inspector.

The lifetime of a message only lasts for one use. Once you've looked at the contents of a message, or copied the contents somewhere, you can't read the message again.

This is a common problem encountered when people are trying to write a message inspector. Since you're expected to pass the message along after you're done inspecting it, it's quite likely that you'll need to make a new copy of the message. If you don't make a copy of the message, then the next person will have nothing to read.

This means that your message inspector code should look something like this:

public void BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
{
MessageBuffer buffer = request.CreateBufferedCopy(int.MaxValue);

// Do something with the copied message reply = buffer.CreateMessage(); buffer.Close(); }
תגים:

תוכן התגובה

# re: This message cannot support the operation because it has been copied

goff כתב/ה

copy-paste: blogs.msdn.com/.../678744.aspx

Monday, August 24, 2009 5:12 PM

שלח תגובה

(שדה חובה) 
(שדה חובה) 
(אופציונלי)
(שדה חובה) 

Enter the numbers above: