RollbarSharp icon indicating copy to clipboard operation
RollbarSharp copied to clipboard

This method or property is not supported after HttpRequest.GetBufferlessInputStream has been invoked.

Open jkatsiotis opened this issue 11 years ago • 7 comments

This error occurs when trying to log an exception that took place inside a WCF Rest Service.

Excerpt from Stacktrace: at System.Web.HttpRequest.EnsureFiles() at System.Web.HttpRequest.get_Files() at RollbarSharp.Builders.RequestModelBuilder.CreateFromHttpRequest(HttpRequest request, HttpSessionState session, String[] scrubParams) at RollbarSharp.Builders.RequestModelBuilder.CreateFromCurrentRequest(String[] scrubParams) at RollbarSharp.Builders.DataModelBuilder.Create(String level, BodyModel body) at RollbarSharp.Builders.DataModelBuilder.CreateExceptionNotice(Exception ex, String message, String level) at RollbarSharp.RollbarClient.SendException(Exception ex, String title, String level, Action1 modelAction) at RollbarSharp.RollbarClient.SendErrorException(Exception ex, String title, Action1 modelAction)

jkatsiotis avatar Feb 15 '14 14:02 jkatsiotis

This appears to be the source of the issue: http://stackoverflow.com/questions/12391586/visual-studio-2012-install-broke-my-2010-wcf-project

Which version of .NET are you running?

I've never used WCF, so I don't know how to reproduce this problem. Does this only happen when you upload files? I'm wondering if this issue only affects attempts to read the files collection or if it happens when trying to read any part of the body.

mroach avatar Feb 17 '14 02:02 mroach

Of course I could wrap everything in try/catch blocks, but when possible I like to detect when an error will occur and handle it in an explicit way.

mroach avatar Feb 17 '14 02:02 mroach

It happens when you try to read the body. It's kind of tricky (if not impossible) to get post data during a WCF request.

I'm afraid the error is more general than the example you are mentioning.

I've tried the above fix but didn't work. Maybe when OperationContext.Current is not null it means that there is a ongoing WCF-enabled request.

On Mon, Feb 17, 2014 at 2:44 AM, Michael Roach [email protected]:

This appears to be the source of the issue: http://stackoverflow.com/questions/12391586/visual-studio-2012-install-broke-my-2010-wcf-project

Which version of .NET are you running?

I've never used WCF, so I don't know how to reproduce this problem. Does this only happen when you upload files? I'm wondering if this issue only affects attempts to read the files collection or if it happens when trying to read any part of the body.

— Reply to this email directly or view it on GitHubhttps://github.com/mroach/RollbarSharp/issues/13#issuecomment-35224920 .

jkatsiotis avatar Feb 17 '14 18:02 jkatsiotis

I got hit by this in my WCF service. I am running .NET 4.5.1.

Any idea how to prevent RequestModel to stop checking for Files during WCF calls?

hab avatar Aug 22 '15 08:08 hab

We are using RollbarSharp at https://github.com/jmblab together with Open RIA Services which uses WCF under the hood. We encountered the same issue so we fixed it with following pull request: https://github.com/mroach/RollbarSharp/issues/42

We decided that information about posted files is not crucial so it is better to log without it than not logging at all.

mzochowski avatar Sep 17 '15 11:09 mzochowski

@hab, @djsolid could you confirm that issue is fixed in your cases?

mzochowski avatar Sep 18 '15 15:09 mzochowski

I upgraded the solution to use .NET 4.5 instead and wrapped the call to request.Files in a conditional checking if was ok like this:

if (request.ReadEntityBodyMode != ReadEntityBodyMode.Bufferless) {
  ...
}

It didn't work in .NET 4.0 so I guess that just ignoring the exception is a viable solution.

hab avatar Sep 18 '15 20:09 hab