[Mono-dev] Compilation error in asp.net 2.0 / Bad classnames
Christian Haller
chris at haller.ch
Sat Feb 25 05:20:26 EST 2006
Hello
I think I found a bug in "System.Web.Compilation/TemplateCompiler.cs".
This is the problem: When I create a simple Webform using Visual Studio 2005
(ASP.Net 2.0) it creats the two (attached) files "Default.aspx" and
"Default.aspx.cs". It runs withount any Problem on MS.Net 2.0. It also works
with the latest release version of Mono (1.1.13). But it doesn't work with
the actual svn version (57270). I'm testing whith "xsp2". When I request the
"Default.aspx" from a Browser I get the following Error:
CS0246: The type or namespace name `Default_aspx' could not be found
You can see the details ins the attached file ("Compilation_Error.html")
Mono generates a temporary source from "Default.aspx.cs". The classname in
this source is "Default_aspx". But the classname in Default.aspx.cs is
"_Default" -> it doesn't match. I tried to find the difference between
monoversion 1.1.13 an the actual version from svn and found it in
"System.Web/Sytem.Web.Compilation/TemplateCompiler.cs". In "InitMethod()" at
line 174 is the follwing code:
if (childrenAsProperties || builder.ControlType ==
null) {
string typeString;
if (builder is RootBuilder) {
typeString = parser.ClassName;
}
else {
if (builder.ControlType != null &&
builder.isProperty &&
!typeof
(ITemplate).IsAssignableFrom (builder.ControlType))
typeString =
builder.ControlType.FullName;
else
typeString =
"System.Web.UI.Control";
}
The classname is generated from "parser.ClassName" or
"builder.ControlType.FullName". In Mono 1.1.13 it is only generated from
"builder.ControlType.FullName". Theo code from "parser.ClassName" looks like
this: (TemplateParser.cs)
className = Path.GetFileName
(inputFile).Replace ('.', '_');
className = className.Replace ('-', '_');
className = className.Replace (' ', '_');
if (Char.IsDigit(className[0])) {
className = "_" + className;
}
The classname is generated from the filename (inlucding the extension). I
think this must be an error. So I removed the changed code from
"TemplateCompiler.cs" to this:
if (childrenAsProperties || builder.ControlType ==
null) {
string typeString;
/*
if (builder is RootBuilder) {
typeString =
parser.ClassName;
}
else
/*
{
if (builder.ControlType != null &&
builder.isProperty &&
!typeof
(ITemplate).IsAssignableFrom (builder.ControlType))
typeString =
builder.ControlType.FullName;
else
typeString =
"System.Web.UI.Control";
}
The classname is only generated from "builder.ControlType.FullName". Now the
Webform ist diplayed without any problems (with xsp2). I don't know the
internals of mono and I don't know the reason for generating the classname
from "parser.ClassName" or "builder.ControlType.FullName". Because of this
i'm not sure if this is a bug or if i'm doing something wrong. But because
it works on MS and with the latest release of Mono I think it is a bug :-)
Thank you
Chris
...and please excuse my bad english
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Default.aspx.cs
Type: application/octet-stream
Size: 363 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060225/ae74b2aa/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Default.aspx
Type: application/octet-stream
Size: 485 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060225/ae74b2aa/attachment-0001.obj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060225/ae74b2aa/attachment.html
More information about the Mono-devel-list
mailing list