none
Error : Cannot evaluate a security function RRS feed

  • Question

  • Hi Guys,

    I have problem with 

    System.Reflection.MethodInfo.GetCurrentMethod().Name method. I make a function to take which class, function whom raise unhandle exception. 

      Try
                'Do something cause exception
            Catch ex As Exception
                Throw New Exception(Me.GetType().Name & "->" & System.Reflection.MethodInfo.GetCurrentMethod().Name & ": " & ex.Message)
            End Try

    but System.Reflection.MethodInfo.GetCurrentMethod().Name also throw exception like "Cannot evaluate a security function".

    Following instruction in Internet, i set my project to "Full trust" but the problem still there.

    Cuong


    Cuong

    Friday, October 26, 2012 3:23 AM

Answers

  • Hi Cuong,

    Welcome to the MSDN Forum.

    Would you like to show me more details about your test project:

    I tried this code in a winform application, it works fine:

            Try
                Throw New Exception("dddd")
            Catch ex As Exception
                Throw New Exception(Me.GetType().Name & "->" & System.Reflection.MethodInfo.GetCurrentMethod().Name & ": " & ex.Message)
            End Try
    

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 26, 2012 1:59 PM
    Moderator
  • Hi Cuong,

    I also tried a class library, it works fine too.

    Here is my test project: http://sdrv.ms/TrAqRJ 

    If I have missed anything, please feel free to let me know.

    Note: Open the project in VS2010, and run the WinForm-CodeDom project, click the button on the pop up form named form1, you will get the method name in the textbox on the form1.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 30, 2012 7:05 AM
    Moderator

All replies

  • Hi Cuong,

    Welcome to the MSDN Forum.

    Would you like to show me more details about your test project:

    I tried this code in a winform application, it works fine:

            Try
                Throw New Exception("dddd")
            Catch ex As Exception
                Throw New Exception(Me.GetType().Name & "->" & System.Reflection.MethodInfo.GetCurrentMethod().Name & ": " & ex.Message)
            End Try
    

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 26, 2012 1:59 PM
    Moderator
  • Hi Cuong,

    Welcome to the MSDN Forum.

    Would you like to show me more details about your test project:

    I tried this code in a winform application, it works fine:

            Try
                Throw New Exception("dddd")
            Catch ex As Exception
                Throw New Exception(Me.GetType().Name & "->" & System.Reflection.MethodInfo.GetCurrentMethod().Name & ": " & ex.Message)
            End Try

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Hi Mike,

    Thanks for your replay. I make an library project, for easy to debug, try make try..catch and throw exception for every method, function. The internal error only show when i throw an exception in project with type is library not execute able project.

    Regards, 


    Cuong

    Tuesday, October 30, 2012 2:06 AM
  • Hi Cuong,

    I also tried a class library, it works fine too.

    Here is my test project: http://sdrv.ms/TrAqRJ 

    If I have missed anything, please feel free to let me know.

    Note: Open the project in VS2010, and run the WinForm-CodeDom project, click the button on the pop up form named form1, you will get the method name in the textbox on the form1.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 30, 2012 7:05 AM
    Moderator