Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving compiler error CS1519: Invalid token ',' in class, struct, or interface member declaration

Tags:

c#

.net

asp.net

I'm working on an ASP .NET 2.0 site which uses a Web Application project file, and therefore compiles to a dll rather than deploying the source code as you do with the older style Web Site projects.

The site works fine on my test server (Windows Server 2003 R2, IIS6) when it runs in the root of a website. However I need to run it under a virtual directory instead. When I switch over to that, I get the following error on browsing to any of the pages in the site

CS1519: Invalid token ',' in class, struct, or interface member declaration

The error message goes onto tell me the line number and code file, however the code file is under the Temporary ASP .NET files folder and when I try to find it, it's not there.

As such I'm unable to work out which page is causing the issue although I suspect it could be the master page, if this error occurs on all pages. Has anyone else seen this before or found a solution?

like image 224
gilles27 Avatar asked Nov 05 '22 22:11

gilles27


1 Answers

Turns out the problem was related to inheriting the config settings of the site above mine in the virtual hierarchy.

That site uses a custom profile whose properties are defined under system.web, profile, properties in the config file. The type of one of the properties was specified in the "Namespace.ClassName, AssemblyName" format.

When I removed the ", AssemblyName" from the end, the issue resolved itself, because I'd got rid of the comma that was the invalid token.

I can only assume that, when ASP .NET compiles pages at runtime, it must have been compiling the profile class too, and using the property definitions in the config file during the code generation.

like image 135
gilles27 Avatar answered Nov 15 '22 07:11

gilles27