0

I would like to know why compilation of default.aspx.cs under Ubuntu Linux 16.04 with a code behind pointing to default.aspx.cs fails when I enter http://127.0.0.1/default.aspx at the web browser. Also, there is a default.aspx.designer.cs file in MyLinuxTest.csproj which is auto generated by Visual Studio and acts like scaffolding for the code one write within the asps and asp.cs files. Because these are auto generated one never should touch or change this file.

I read today on www.monoproject.com FAQ that default.aspx.cs is always compiled . A few days ago I read that default.aspx.cs is compiled only once when it has changed. I read also there is an aspx CompilationMode server side script option, Always, Auto and Never. What is the correct compilation behavior for the mod_mono_server4 process? Please correct my use of terminology.

Here is what I did yesterday. Because of the C# rule which says that classes beginning with @ can only be followed by a C# keyword. As a result, compilation failed even with MonoDevelop Xamarin Studio 5.5 when I used a C# class named @default. To rectify that error I was directed to change the class name @default to abcdef in two places, default.aspx and default.aspx.designer.cs.

When I finished those changes, I built MyLinuxTest.csproj using MonoDevelop Tamarin Studio 5.5 and generated a MyLinuxTest.dll which I tested with Run With Firefox browser so as to launch xsp4 and it functioned correctly at this point in time.

Next I copied MyLinuxTest.dll and MyLinuxTest.dll.mdb to our production environment's bin folder. [EDIT I read in the mono-project.com FAQ document today that these files need to be installed using rm MyLinuxTest.dll followed by cp /home/frankc/Downloads/MyLinuxTest/MyLinuxTest/bin/MyLinuxTest*.* ..

At this time, When I used my Chrome web browser and apache2's mod_mono_server4 like this http://127.0.0.1/default.aspx, so I got the C# compiler error temporary aspx.cs could not compile because there was an ASP class method default_aspx already defined. How could I fix this baffling C# compiler error so that http://127.0.0.1/default.aspx delivers the correct Web content? I can supply the ASP.NET code if requested. Should default.aspx and default.aspx.cs be renamed to Default.aspx and Defalt.aspx.cs which I used successfully in HelloWorld.csproj? Also, what should I do to recover or remove default.aspx.designer.cs from the compilation process?

  • I'm confused, classes beginning with @ don't have to be followed by a keyword. Also, default is a keyword in C#. – svick Jun 18 '16 at 21:22
  • @svick, Thank you for your nice comment. I agree with you about classnames.Should I change my C# classname to something else from @default?What should I do about the classname @ default in default.aspx.designer.cs since it automatically generated by the Microsoft Visual Studio compiler. May I show you these files? – Frank Jun 18 '16 at 23:10
  • @Anthon, I appreciate your great edit. Please tell me what I may have done wrong to cause this C# compiler error. Should I display a file or two? Thank you. – Frank Jun 18 '16 at 23:46
  • @svick, You are totally wrong about C# class names beginning with @, Take a look at this URL : stackoverflow.com/questions/950616/… which says:The spec details are here. Essentially, any unicode character (including unicode escapes) in the character classes Lu, Ll, Lt, Lm, Lo, Nl, Mn, Mc, Nd, Pc, and Cf. The first letter is an exception and it must be a letter (classes Lu, Ll, Lt, Lm, or Lo) or an underscore. Also, if the identifier is a keyword, you must stick an @ in front of it. The @ is optional otherwise. Please stop confusing. – Frank Jun 19 '16 at 2:04
  • I don't understand, how does that contradict what I said? class @normalName {} is fine and so is class @default {}. I believe I said that and so does the answer you're quoting. – svick Jun 19 '16 at 2:11
0

After trying @svick 's suggestion to change my class name from @default to @normalName, I still got the following error message and stack trace:

Details: Cannot find type MyLinuxTest.@normalName

Error origin: Parser

Error source file: /var/www/firstaspnet/default.aspx
Exception stack trace:
  at System.Web.UI.BaseParser.ThrowParseException (System.String message, System.Object[] parms) <0x40c61680 + 0x00087> in <filename unknown>:0 
  at System.Web.UI.TemplateParser.SetBaseType (System.String type) <0x40c555c0 + 0x000cf> in <filename unknown>:0 
  at System.Web.UI.TemplateParser.ProcessMainAttributes (IDictionary atts) <0x40c5fa40 + 0x00bbf> in <filename unknown>:0 
  at System.Web.UI.TemplateControlParser.ProcessMainAttributes (IDictionary atts) <0x40c5ea50 + 0x00423> in <filename unknown>:0 
  at System.Web.UI.PageParser.ProcessMainAttributes (IDictionary atts) <0x40c5be30 + 0x02773> in <filename unknown>:0 
  at System.Web.UI.TemplateParser.AddDirective (System.String directive, IDictionary atts) <0x40c5b720 + 0x0019a> in <filename unknown>:0 
  at System.Web.UI.TemplateControlParser.AddDirective (System.String directive, IDictionary atts) <0x40c5b190 + 0x00523> in <filename unknown>:0 
  at System.Web.UI.PageParser.AddDirective (System.String directive, IDictionary atts) <0x40c5acb0 + 0x0046f> in <filename unknown>:0 
  at System.Web.Compilation.AspGenerator.GetInheritedType (System.String fileContents, System.String filename) <0x40c58000 + 0x003fd> in <filename unknown>:0 
  at System.Web.Compilation.AspGenerator.GetRootBuilderType (System.IO.Stream inputStream, System.String filename) <0x40c574a0 + 0x000bf> in <filename unknown>:0 
  at System.Web.Compilation.AspGenerator.CreateRootBuilder (System.IO.Stream inputStream, System.String filename) <0x40c572b0 + 0x0003b> in <filename unknown>:0 
  at System.Web.Compilation.AspGenerator.InitParser (System.IO.TextReader reader, System.String filename) <0x40c56760 + 0x00353> in <filename unknown>:0 
  at System.Web.Compilation.AspGenerator.Parse (System.IO.TextReader reader, System.String filename, Boolean doInitParser) <0x40c56360 + 0x00063> in <filename unknown>:0 
  at System.Web.Compilation.GenericBuildProvider`1[TParser].Parse () <0x40c4fbb0 + 0x000c3> in <filename unknown>:0 
  at System.Web.Compilation.GenericBuildProvider`1[TParser].GenerateCode () <0x40c4fae0 + 0x00016> in <filename unknown>:0 
  at System.Web.Compilation.GenericBuildProvider`1[TParser].GenerateCode (System.Web.Compilation.AssemblyBuilder assemblyBuilder) <0x40c4f8d0 + 0x0004c> 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) <0x40c4ecf0 + 0x002da> in <filename unknown>:0 

I discovered the way to fix my problem was to 1) reinstall all my apache2, Mono and ASP.NET packages in the correct order 2) change my class name from @default to abc.

It is important to install to install the apache2 package first.Also, it is necessary to install sudo apt-get install mono-apache-server4 before sudo apt-get install libapache2-mod-mono because the package mono-apache-server4 is a prerequisite of the package libapache2-mod-mono.

  • I also changed the name of default.aspx to Default.aspx to avoid a naming collision with the ASP class default_aspx method(). – Frank Jun 20 '16 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.