Bug 17269 - System.Web.Compilation.CompilationException in ASP.NET with CS1576
Summary: System.Web.Compilation.CompilationException in ASP.NET with CS1576
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 3.0.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-01-16 06:08 UTC by Andre Raabe
Modified: 2017-01-08 00:39 UTC (History)
6 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Full error screen (44.84 KB, image/png)
2014-01-16 06:08 UTC, Andre Raabe
Details

Description Andre Raabe 2014-01-16 06:08:53 UTC
Created attachment 5854 [details]
Full error screen

During the on-demand compilation of an ASP.NET site I get a System.Web.Compilation.CompilationException with "CS1576: The line number specified for #line directive is missing or invalid".

Repro:

  - Create empty directory e.g. /tmp/f1

  - Create trival site e.g. default.aspx:
    -------8<---[default.aspx]----
    <html>
    <body>
    Hello
    </body>
    </html>
    ------->8---[default.aspx]----

  - Create trival web.config
    -------8<---[web.config]----
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
       <system.web>
       <compilation defaultLanguage="c#" debug="true"/>
       <customErrors mode="Off"/>
       </system.web>
       <system.webServer>
           <defaultDocument>
           <files>
               <clear/>
               <add value="Default.aspx"/>
           </files>
          </defaultDocument>
      </system.webServer>
    </configuration>
    ------->8---[web.config]----

  - Start "xsp2" in directory and visit URL

  --> Expected: Site says "Hello" but got exception. (Source file content available here: https://gist.github.com/anonymous/8453123)


mono --version
Mono JIT compiler version 3.0.6 (tarball Sat Sep 28 04:42:52 UTC 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)

Bug is reproducible in standard OpenSuSE 13.1 edition (comes with mono 3.0.6). http://software.opensuse.org/131/en
Comment 1 Arsen.Shnurkov 2014-10-21 04:24:37 UTC
I have same or similar bug on Calculate linux

System.Web.Compilation.CompilationException
CS1576: The line number specified for #line directive is missing or invalid

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Details: CS1576: The line number specified for #line directive is missing or invalid

Error origin: Compiler

Error source file: /login/Default.aspx
Exception stack trace:
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] in <filename unknown>:0 at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0 at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0 at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0 

Version Information: 3.8.0 ((detached/45d0ba1 Sun Oct 12 23:47:17 Local time zone must be set--see zic manual page 2014); ASP.NET Version: 2.0.50727.1433
Comment 2 Arsen.Shnurkov 2014-10-21 04:33:03 UTC
see also this page:
http://ubuntuforums.org/showthread.php?t=2240319
(the same thing with   asp .net version 4)
Comment 3 Casey Gregoire 2015-04-12 22:32:12 UTC
I compiled Mono on Ubuntu 14.04 today by following these instructions
http://www.bgsoftfactory.net/run-asp-net-mvc-4-with-mysql-on-linux/

though I had to get the latest Mod_mono to make it work instead of the version specified.

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Details: CS1576: The line number specified for #line directive is missing or invalid

Error origin: Compiler

Error source file: /tmp/www-data-temp-aspnet-0/faff594a/App_Web_29cdd875_0.cs
Exception stack trace:
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00365] in /home/ubuntu/monobuild/mono/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:853 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /home/ubuntu/monobuild/mono/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:731 
  at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00264] in /home/ubuntu/monobuild/mono/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:846 
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /home/ubuntu/monobuild/mono/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:469 
Error source context:

Error lines: 85
83:             System.Web.UI.IParserAccessor __parser = ((System.Web.UI.IParserAccessor)(__ctrl));
84:             
85:             #line 0 ""
86:             __parser.AddParsedSubObject(new System.Web.UI.LiteralControl("<html>\n<body>\nstuff\n</body>\n</html>\n"));
87:
Comment 4 Casey Gregoire 2015-04-12 23:07:12 UTC
Let me add, this same page works on the current release of Mono on both mac and windows.
Comment 5 IJsbrand Oudshoorn 2015-05-09 05:53:00 UTC
Hi all,

I get this very same error, just like Andre Raabe reported.

Casey, you wrote it works with the current release on Mac and Windows.
But unfortunately, it doesn't seem to be fixed for Linux.

I am running Mono version 4.0.1 on Debian GNU/Linux 7 (wheezy).
To my knowledge this 4.0.1 is the latest version available.

# mono --version
Mono JIT compiler version 4.0.1 (tarball Tue Apr 28 11:47:58 UTC 2015)


Since Andre reported this bug already in version 3.0.6 (Sep 28, 2013) I am wondering how others are running .aspx files on their Linux servers?

Is there a known workaround?

Exact error I get:

System.Web.Compilation.CompilationException
CS1576: The line number specified for #line directive is missing or invalid

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Details: CS1576: The line number specified for #line directive is missing or invalid

Error origin: Compiler

Error source file: /mobile/index.aspx
Exception stack trace:
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] in <filename unknown>:0 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0 
  at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0 
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0 
Version Information: 4.0.1 (tarball Tue Apr 28 11:47:58 UTC 2015); ASP.NET Version: 4.0.30319.17020
Comment 6 IJsbrand Oudshoorn 2015-05-09 06:53:35 UTC
Hi all,

After trying a lot of things it turns out that the first line of every .aspx file has to start with the <%@ Page .... %>. So the simple test files Andre and I were using were too simple. 

Test file that works:

--- FILE index.aspx ---
<%@ Page Language="C#" %>
<html>
<head>
        <title>Hello World!</title>
</head>
<body>
        <p>Hello World!</p>
</body>
</html>
--- END OF index.aspx ---

The error reported is very confusing and let people believe there is something wrong with the configuration, see for example:
 *  http://mono.1490590.n4.nabble.com/CS1576-after-upgrade-to-Ubuntu-14-04-1-td4663599.html
 *  http://ubuntuforums.org/showthread.php?t=2240319

So it would be very convenient if this user mistake is reported more clearly and more nicely to the user.
Comment 7 Adrienne 2015-11-06 17:57:30 UTC
I'm also getting the same error, BUT only with files I have placed in a sub-directory/folder within my solution. Once I move those files out of the directory, they work just fine - go figure!! I created a brand-new sub-folder and aspx page to test this and confirmed the problem happens again. This ONLY started happening when I finally updated Xamarin to the latest "stable" release. I tried every target framework as well...no difference. Here's the environment info:
Xamarin Studio
Version 5.9.8 (build 0)
Installation UUID: 9e8c2541-8d72-4721-a3ed-75b36b9927fc
Runtime:
	Mono 4.0.5 ((detached/1d8d582)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400050001

Xamarin.Android
Version: 5.1.9.0 (Starter Edition)
Android SDK: /Users/Adrienne/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Xamarin Android Player
Not Installed

Apple Developer Tools
Not Found

Xamarin.iOS
Version: 9.1.0.27 (Starter Edition)
Hash: 1f068b4
Branch: master
Build date: 2015-10-27 18:59:21-0400

Xamarin.Mac
Not Installed

Build Information
Release ID: 509080000
Git revision: cc5f6e5658589ca7f46210c57fad947e75f30abd
Build date: 2015-10-21 19:27:41-04
Xamarin addins: d77f191bd7d3451adf837b85b38f2b7c60004400

Operating System
Mac OS X 10.9.5
Darwin Adriennes-Mac-mini.local 13.4.0 Darwin Kernel Version 13.4.0
    Wed Mar 18 16:20:14 PDT 2015
    root:xnu-2422.115.14~1/RELEASE_X86_64 x86_64

and the stack trace:
 at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00365] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr5/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.5/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:853 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr5/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.5/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:731 
  at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00264] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr5/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.5/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:826 
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr5/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.5/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:451
Comment 8 IJsbrand Oudshoorn 2015-11-18 08:08:03 UTC
Hi Adrienne,

Do your aspx files start with the line:

<%@ Page Language="C#" %>

(or other language if applicable)?

As you can see in my comments of May, I got this same problem after updating. Making sure all my files started with <%@ Page ... %> did fix the problem for me.
Comment 9 Adrienne 2015-11-18 09:48:17 UTC
Yes, I confirmed all my pages start with the @Page directive in the very first line. I narrowed the issue down to the files being in any sub-directory. If I moved any of the files back to the main application folder, they worked just fine with no code modification.
Comment 10 Simon Egli 2017-01-08 00:39:56 UTC
The bug also happens, when you load an aspx page from a virtual path provider.

Note You need to log in before you can comment on or make changes to this bug.