[Mono-list] null ref. exception

Peter Hagen peter at wingsofdeath.nu
Mon Jul 20 06:57:18 EDT 2009


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.

[EditorBrowsable (EditorBrowsableState.Advanced)]
[Browsable (false)]
[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
public string AppRelativeTemplateSourceDirectory {
        get {
                if (_appRelativeTemplateSourceDirectory != null)
                        return _appRelativeTemplateSourceDirectory;

                string tempSrcDir = null;
                TemplateControl templateControl = TemplateControl;
                if (templateControl != null) {
                        string templateVirtualPath =
templateControl.AppRelativeVirtualPath;
                        if (!String.IsNullOrEmpty (templateVirtualPath))
                                tempSrcDir =
VirtualPathUtility.GetDirectory (templateVirtualPath, false);
                }

                _appRelativeTemplateSourceDirectory = (tempSrcDir !=
null) ? tempSrcDir : VirtualPathUtility.ToAppRelative
(TemplateSourceDirectory==string.Empty?"/":TemplateSourceDirectory);
                return _appRelativeTemplateSourceDirectory;
        }
        [EditorBrowsable (EditorBrowsableState.Never)]
        set {
                _appRelativeTemplateSourceDirectory = value;
                _templateSourceDirectory = null;
        }
}

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?

Cheers

Peter

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.
> 
> -Gonzalo
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090720/c43787c2/attachment-0001.html 


More information about the Mono-list mailing list