[Mono-list] null ref. exception
grendel at twistedcode.net
Mon Jul 20 07:18:33 EDT 2009
Peter Hagen wrote:
> Hi Gonzalo
> I did some tests on ./mcs/class/System.Web/System.Web.UI/Control.cs and
> noticed if the TemplateSourceDirectory is empty, I get the crash.
> So, i added this line, which is probably not ok, but it works now. Im
> not sure what the TemplateSourceDirectory should be in this case. Do you
> have a suggestion?
It should always be set to the virtual directory of the current control's parent.
TemplateSourceDirectory can be empty only in those cases (2.0 profile):
1. this.TemplateControl is null and HttpContext.Current is null and the current control is not a
2. current control is a TemplateControl and this.AppRelativeVirtualPath is null, which can happen
only if AppRelativeVirtualPath is never initialized from code generated by ASP.NET compiler.
3. We have a bug in 2.0 logic for Control.TemplateSourceDirectory
My bet is on #2, which would mean that your application is incorrectly ported to 2.0 - make sure
that you run it with the 2.0 runtime, that all your code-behind and referenced assemblies are
compiled with the 2.0 compiler. It is possible that some of your controls use the 1.1 version of
System.Web and thus hit the 1.1 path in Control.TemplateSourceDirectory.
> On Mon, 2009-07-20 at 00:02 -0400, Gonzalo Paniagua Javier wrote:
>> On Sun, 2009-07-19 at 18:40 +0200, Peter Hagen wrote:
>> > Hi Gonzalo
>> > well, i have a bit a problem of recreating the bug in a new project.
>> > If i make a new project from MonoDevelop, it works as planned. But
>> > inside my project it doesn't. But this is originally a 1.1
>> > application. Uploading the entire project isnt really an option. So,
>> > ill try to figure out more about the project first :s
>> If you can build System.Web from sources, sprinkle a few
>> Console.WriteLine() in Contorl.AppRelativeTemplateSourceDirectory and
>> ToAppRelative. That will at least tell you where the 'null' is used for
>> the first time.
>> Mono-list maillist - Mono-list at lists.ximian.com <mailto:Mono-list at lists.ximian.com>
> Mono-list maillist - Mono-list at lists.ximian.com
More information about the Mono-list