MyPart would be the type, part is the variable to which the instance of the
type is assigned.

From:  Antonio Chagoury <[email protected]>
Reply-To:  <[email protected]>
Date:  Mon, 31 Jan 2011 14:52:17 -0500
To:  <[email protected]>
Subject:  Re: Interesting NullRef in a Driver

I am not an expert with Orchard *by any stretch of the imagination*, but
should your check be if(MyPart == null) ... ?



Antonio Chagoury - Microsoft MVP
CEO & Chief Software Architect | Inspector IT
703-862-3993 Direct
[email protected] Email
http://www.inspectorit.com Web
http://www.cto20.com Blog

Follow us on Twitter: @InspectorIT, @AntonioChagoury


On Mon, Jan 31, 2011 at 2:45 PM, Paul Vencill <[email protected]> wrote:
> I had an interesting issue last night that took me a while to resolve, and
> while it's "fixed" for my purposes, I'm a bit stumped as to what's going on
> under the hood and was hoping someone would know.
> 
> The scenario is that I was writing a Driver for my contentpart, and when
> overriding the (GET) Editor method, I threw in a null check on the part (even
> though it really should never be null).  Partially out of habit, and partially
> b/c I was about to call on its properties to make some decisions on the shape
> I was creating.  In essence:
> 
> protected override DriverResult Editor(MyPart part, dynamic shapeHelper)
> {   
>    if(part == null){
>         // make some defaults
>    }
>    // ... etc & return
> }
> 
> So the interesting things are that a) the line part==null  throws a null
> reference exception.  I wouldn't expect it to do that even if part is null,
> but when stepping through I can see that part is initialized to an instance of
> MyPart; so it's even more confusing.  b) I can't set breakpoints past that
> line, either. I get an error from Visual Studio that the CLR could not set the
> breakpoints on the line in question.
> 
> I have worked around it in my part by just dropping the check and assuming
> that part is never null, but this is behavior that I don't think I could
> replicate if I wanted to.  Any idea why it's occurring?
> 
> Paul
> --- You are currently subscribed to orchard-discuss as:
> [email protected]. To unsubscribe send a blank email to
> [email protected].

--- You are currently subscribed to orchard-discuss as: [email protected].
To unsubscribe send a blank email to
[email protected].



---
You are currently subscribed to orchard-discuss as: [email protected].
To unsubscribe send a blank email to [email protected].

Reply via email to