c# - The name '__o' does not exist in the current context -
i installed visual studio 2015 , opened asp .net project working on. i'm receiving many errors (all same) below:
error cs0103 name '__o' not exist in current context
well don't have variables named __o , code works charm (error invalid) bothers me i'm not able see when code has error goes somewhere in list , should check whole list.
i found out if choose build only instead of build + intellisense errors (that related intellisense) go away.
update 1: reason
the reason happening codes this:
<% if (true) { %> <%=1%> <% } %> <%=2%>
in order provide intellisense in <%= %> blocks @ design time, asp.net generates assignment temporary __o variable , language (vb or c#) provide intellisense variable. done when page compiler sees first <%= ... %> block. here, block inside if, after if closes, variable goes out of scope. end generating this:
if (true) { object @__o; @__o = 1; } @__o = 2;
the workaround add dummy expression in page. e.g. <%="" %>. not render anything, , make sure __o declared top level in render method, before potential if (or other scoping) statement.
update 2: getting rid of error without loosing other intellisense errors
click on filter button on top left corner of error list panel , uncheck cs0103 error code the: the name '__o' not exist in current context , these errors not shown anymore , can still have other intellisense errors , warnings:
Comments
Post a Comment