Whether using (HttpResponseMessage) == Response.End (.Redirect) code ... is optimized or native frame

I am getting this error and google / SO makes it pretty clear this error is specific to using Response.Redirect or Response.End

{The expression cannot be evaluated because the code is optimized, or the native frame is on top of the call stack.}

Microsoft specifically describes this as "by design" and suggests using the best method to achieve the desired effect here.

The code I am helping to eliminate does NOT use the specified methods like Response.End, but has a using statement, so I'm wondering if the compiler translates the usage into one of the unwanted calls like Response.End

Here is the link where the error starts:

HttpRequestMessage request = HelperBuildRequest( client, "abc/123", HttpMethod.Get, ssoToken, "application/vnd.widgets.search.product-v1.0+json" );

using ( HttpResponseMessage response = client.SendAsync( request ).Result )
{
   Action<SearchProductsResponseModel> action = ( result ) =>
   {
      .....doing stuff...
   };
  json = HelperResponse<SearchProductsResponseModel>( response, MethodBase.GetCurrentMethod().Name, action );
}

      

When I terminate it with a try catch, I get the same ... I was hoping for something more specific.

So does anyone know how the compiler implements the use, or perhaps the interaction between the use and the System.Action delegate, or ... are there really any other ideas?

TIA

OK, so back from other stuff and following the suggestion, I caught the error trap and looked at the locals to see what the moment and YOWSER are.

Absolutely I haven't used the debugger to the fullest for this problem. A screenshot will make it all clear.

enter image description here

So usr make your comment an answer and I'll tag it right away.

THANK

+3


source to share


1 answer


This is no exception, debugger output. Look at the locals window or post a screenshot. Update: indeed, you found the bug this way.

I have not used the debugger fully for this problem



Yes.

+1


source







All Articles