none
Will Caller Information work in Release Mode? RRS feed

  • Question

  • Hi,

    I want to track the method name, line number and file name when exception occurs in ASP .NET 4.5 Production environment. The code will be released in 64 bit environment without .PDB files.

    Will the following code still work in 64 bit release mode without .PDB files? Please suggest.

    [CallerMemberName] string memberName = "",
    [CallerFilePath] string sourceFilePath = "",
    [CallerLineNumber] int sourceLineNumber = 0


    Amit Kumar Tiwari

    Thursday, February 4, 2016 10:30 PM

Answers

  • Hi Matheyo,

    >>Will the following code still work in 64 bit release mode without .PDB files?

    Yes, it is. If I have a TestCallerMethod method and invoke it using TestCallerMethod();

    public static void TestCallerMethod([CallerMemberName] string memberName = "",
            [CallerFilePath] string sourceFilePath = "",
            [CallerLineNumber] int sourceLineNumber = 0)
    {
        Console.WriteLine(memberName);
        Console.WriteLine(sourceFilePath);
        Console.WriteLine(sourceLineNumber);
    }
    static void Main(string[] args)
    {
        TestCallerMethod();
        Console.Read();
    }

    After I compiled it. TestCallerMethod() will be changed to below code automatically. The compiler will get current information and change our code.

    Program.Method("Main", "c:\\Users\\xxxUser\\Documents\\Visual Studio 2013\\Projects\\myProjectName\\CSharpConsoleApplication\\Program.cs", 55);
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Matheyo Wednesday, February 10, 2016 3:40 PM
    Friday, February 5, 2016 5:29 AM
    Moderator

All replies

  • Hi Matheyo,

    >>Will the following code still work in 64 bit release mode without .PDB files?

    Yes, it is. If I have a TestCallerMethod method and invoke it using TestCallerMethod();

    public static void TestCallerMethod([CallerMemberName] string memberName = "",
            [CallerFilePath] string sourceFilePath = "",
            [CallerLineNumber] int sourceLineNumber = 0)
    {
        Console.WriteLine(memberName);
        Console.WriteLine(sourceFilePath);
        Console.WriteLine(sourceLineNumber);
    }
    static void Main(string[] args)
    {
        TestCallerMethod();
        Console.Read();
    }

    After I compiled it. TestCallerMethod() will be changed to below code automatically. The compiler will get current information and change our code.

    Program.Method("Main", "c:\\Users\\xxxUser\\Documents\\Visual Studio 2013\\Projects\\myProjectName\\CSharpConsoleApplication\\Program.cs", 55);
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Matheyo Wednesday, February 10, 2016 3:40 PM
    Friday, February 5, 2016 5:29 AM
    Moderator
  • Thank you so much for your answer and sorry for late response.

    I tried clicking the survey link but it says "This page does not exist."


    Amit Kumar Tiwari

    Wednesday, February 10, 2016 3:40 PM