[Mono-dev] How to compile using App_Code folder
grendello at gmail.com
Tue Nov 28 17:11:56 EST 2006
On Tue, 28 Nov 2006 23:13:05 +0200, "Piotr Stulinski"
<jamjar at gmail.com> scribbled:
> I am struggling to get my site working with 1.2.1 - App_Code
> functionality. I have 3 simple pages.
> a Class1.cs in my App_Code folder with literally one method:
> public static void HelloWorld()
> return "hello world";
C# doesn't allow for methods defined in the main body of a compilation
unit. Each compilation unit (a .cs or .vb etc file) must contain only
type (class, enum, struct) or namespace declarations which in turn
contain methods. That's issue no 1 with the code above. Issue no 2 is
that your function declares a void (nothing) return type, while it
tries to return a string. Your Class1.cs should look like:
public class Class1
public static string HelloWorld()
return "hello world";
> a Default.aspx.cs
> in the Load method i have
> Label1.Text = Class1.HelloWorld();
> and finally i have the
> Default.aspx page with only
> Label1 on it.
> I have not changed any of the other Visual Studio 2005 settings extra,
> i am not sure if i am supposed to? But when i execute it under the
> above scenario i get a error:
> Description: Error compiling a resource required to service this
> request. Review your source file and modify it to fix this error.
> Error message:
> /opt/mono_home/code/Default.aspx.cs(15,23) : error CS0103: The name
> `Class1' does not exist in the context of `_Default'
That's a correct behavior - due to errors I pointed out above re
> File name: /opt/mono_home/code/Default.aspx
> Source File: /opt/mono_home/code/Default.aspx.cs
> Line 1: No assembly returned after compilation!?
> I am very new to compiling under mono. What i do know is that it works
> 100% if i dont use the Class1.cs file. So for example if i go
> Lavel1.Text = "Hello World";
> that does work...
> Any help or a mini tutorial or something on compiling would be great
> doesnt seem to be much info around.
Well, there's nothing mono-specific in compiling C# code, provided your
program is indeed valid C#. Please make the changes I described,
re-test your application and let us know if it worked for you
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061128/63d1ff6d/attachment.bin
More information about the Mono-devel-list