When attempting to load in a browser an ASP.NET web form (.aspx page) that I'm working on, I get the following runtime error:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1519: Invalid token 'this' in class, struct, or interface member declaration
Source Error:
Line 447: #line default
Line 448: #line hidden
Line 449: this.@__PageInspector_EndRenderTracing(new object[] {
Line 450: @__w});
Line 451: this.@__PageInspector_BeginRenderTracing(new object[] {
The code quoted in the error message doesn't appear in any of my own code.
My project builds ok.
What's the cause of this error?
In my situation, this error was caused by an extra/unbalanced closing curly bracket ("}" character) in a server-side code block in my .aspx file.
In other words, this error can be reproduced by creating an empty ASP.NET web form, and then inserting the following into the .aspx page somewhere:
<% } %>
I hadn't initially noticed, but despite the project building ok, Visual Studio was also reporting an error in the "Error List" window for my .aspx page: Type or namespace definition, or end-of-file expected
Tracking down the extra "}" character, deleting it, and reloading my page in the browser fixed the problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With