Skip to content

Compiler optimizing needed variable away #34799

@liadpaz

Description

@liadpaz

I'm developing an UWP app and I'm using a REST client that I have developed by myself. I have checked the REST client independently, and it works just as expected. But when using it on the UWP app I get a null reference exception for a variable that I assigned a value from the REST client.
When I'm debugging and pinning a breakpoint on the the assignment line it works, also if I'm writing "Debug.WriteLine($var)" after assigning the value to the variable it works just fine. Also I tried to put the no optimization attribute on the method.

I don't know if it's the right format or place to post this, if it's not please let me know

EDIT: On release configuration the "Debug.WriteLine($var)" have no effect but "Console.WriteLine($var)" does make it work as intended

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-UWPuntriagedNew issue has not been triaged by the area owner

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions