[Mono-list] null ref. exception
Marek Habersack
grendel at twistedcode.net
Mon Jul 20 11:44:45 EDT 2009
Peter Hagen wrote:
> Ow, and I forgot to mention, it does work under 2.0.1, but not with
> 2.4.2.2
Well, it's hard to determine what causes it without seeing the app/sample/test case. If you can give
Gonzalo or I access to a server with the application (shell would be required), or share (privately)
the source with either us, that'd be helpful.
regards,
marek
>
> Cheers
>
> Peter
>
> On Mon, 2009-07-20 at 15:27 +0200, Peter Hagen wrote:
>> Hi Marek
>>
>> you are right, there were some projects at 1.1. Yesterday I changed
>> that, but I seemed not to have checked in my changes. I now am sure
>> that all the controls (even NeatUpload) are compiled as 2.0, but still
>> the exception occures. Im sure that the exception is throw by the
>> IsAbsolute method:
>>
>>> public static bool IsAbsolute (string virtualPath)
>>> {
>>> if (StrUtils.IsNullOrEmpty (virtualPath))
>>> throw new ArgumentNullException ("virtualPath");
>>>
>>> return (virtualPath [0] == '/' || virtualPath [0] == '\\');
>>> }
>> when I print the value of virtualPath, it is indeed empty (but not null). If I just compile a control which was made for 1.1 as a 2.0 project, then things should be ok? The control that gives the exception is the neatupload inputcontrol which is derived from the FileContol, which comes from the System.Web.UI.WebControls.WebControl. I guess that should be no problem?
>>
>> public abstract class FileControl : System.Web.UI.WebControls.WebControl, System.Web.UI.IPostBackDataHandler
>>
>> Cheers
>>
>> Peter
>>
>> On Mon, 2009-07-20 at 13:18 +0200, Marek Habersack wrote:
>>> 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.
>>>>
>>> [snip]
>>>> 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
>>> TemplateControl
>>> 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.
>>>
>>> regards,
>>>
>>> marek
>>>
>>>> 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 <mailto:Mono-list at lists.ximian.com>
>>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> Mono-list maillist - Mono-list at lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
More information about the Mono-list
mailing list