CS0103 everywhere RRS feed

  • Question

  • User-1509082428 posted

    We have a web forms application that has been around for a good while, lots of in-place framework upgrades and such to keep it poking along.  At some point several years ago we arrived at a point where now anytime we open a .aspx page, all of our markup with <%= %> references to protected properties on the underlying .cs show CS0103 errors.  Everything still works fine, but it has made ongoing maintenance and development a real pain.

    We came up with the theory that it was probably some outdated way of doing things that was left over from a prior upgrade, and that maybe we should take the time to figure out how to get it all sorted out.  To try and do that investigation, I created a brand new web forms project in Visual Studio 2019 using the built in template and to my utter bewilderment that project exhibits the exact same behavior.  I created a step-by-step gallery of how I created the project and the behavior I'm seeing.

    Please someone, help restore our sanity because we're losing our minds over here!


    Gallery of steps to create & test project:


    Wednesday, July 31, 2019 6:18 PM

All replies

  • User409696431 posted


    <%= Text %>

    to work in the .aspx page, change

    protected string Test {get { return "Please work"; }}


    public string Test {get { return "Please work"; }}


    public string Test {get { return _testValue; }}
    private string _testValue = "Please work";


    public string Test {get { return _testValue; }}
    protected string _testValue = "Please work";

    Or just:

    protected string _testValue = "Please work";

    And with the above change, use that protected string value in the .aspx page:

    <%= _testValue %>

    Thursday, August 1, 2019 1:52 AM
  • User-719153870 posted

    Hi FrayedString,

    The CS0103 error in your demo means that you can't find your "Test" value in the back. However, your demo actually works well that it shows the message in the about page in the gallery provided.

    I built a same demo and met the same error, but when i view in browser it also show the Test message.

    After this, i saw the CS0103 error in my demo disappeared. Is this the same situation for you? Did your CS0103 error message disappear?

    The i put some other "Test" in this page and the error never show again, until i put a "Test3" that i didn't define in the back code.

    In my opinion, the conclusion is that for the first time, vs might not have responded in time.

    Below is screenshots of my demo:

    The CS0103 error occured when the variable not defined in the back.

    You can see there's a "1 reference" above the variable definition which used in the front code, and "0 references" for which not used.

    In the gallery you provided we can see that the "Test" is with "0 references", but it worked well in the page. This is the evidence for the conclusion.

    If you still get this error, please tell and we will try our best to help.

    Best Regard,

    Yang Sen

    Thursday, August 1, 2019 2:24 AM
  • User409696431 posted

    There is some confusion here.  The original post says <%=  %>, and your demo says <%:  %>.  Using <%= it does not work - there is an error page with the undefined error.  (My suggested changes options fix that.)

    Frankly, the image the original poster uploaded has a line interfering with the <%... and I can't see if it is = or :

    Thursday, August 1, 2019 2:28 AM