Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

System.Reflection.MethodInfo.GetCurrentMethod.Name now throwing "Cannot Evaluate Security Function" error in Try...Catch

$
0
0

For the last five months I've been working on an ASP.NET 4.5 project using VS2013 Ultimate and Visual Basic. I've been developing on my location machine, using local ISS and a networked SQL 2012 server. 

I've been using the following in this dev environment to catch mistakes since I'm new at ASP.NET:

Catch ex As Exception
            Trace.Warn(ex.ToString())
            If ShowAlerts Then System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">alert(""" + currentMethod + ": " + isNull(ex.Message)+ """)</SCRIPT>")
        End Try

However, in the last couple weeks it has started to throw the following error: "Cannot evaluate a Security Function" 

This happens every time methodinfo is called inside that try...catch. However, if I declare a string and assign it inside the function, but above the catch:

DimcurrentMethodAsString

Try

      currentMethod = System.Reflection.MethodInfo.GetCurrentMethod.Name

      {insert code here}

CatchexAsException

            Trace.Warn(ex.ToString())

           IfShowAlertsThenSystem.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">alert("""+ currentMethod +": "+ isNull(ex.Message) +""")</SCRIPT>")

       EndTry


I no longer get an error. But I don't want to be calling methodinfo unless I need to (it is very expensive, after all), and I really dislike the idea of creating custom error messages for every single method so I know what method triggered the alert message.

Similarly, an associate of mine linked me that he had a similar problem start in the last week of January 2015, with MethodInfo  sing the watch functionality of VS. He posted it at

https://social.msdn.microsoft.com/forums/vstudio/en-US/008a06ed-92bf-40b4-8bc7-a6286a394ec8/error-cannot-evaluate-a-security-function

I've found similar posts as far back as 2008 saying that you need to change permissions. That has not seemed to help. And it does not explain why I have suddenly had the error start only a few weeks ago after 4 months of not having the error.

Does anyone know what I could try to resolve this? 

Thanks!

--Cralis



Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>