Silverlight logging out causes "Object reference not set to an instance"

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-04-23T23:27:06Z Indexed on 2010/04/23 23:33 UTC
Read the original article Hit count: 180

I am using the Silverlight 4 Business Application Template. I've created a DomainDataSource in XAML like so:

<riaControls:DomainDataSource x:Name="LogData" QueryName="GetLogs" AutoLoad="True" LoadSize="20" >
        <riaControls:DomainDataSource.DomainContext>
            <local:AdminDomainContext />
        </riaControls:DomainDataSource.DomainContext>
        <riaControls:DomainDataSource.QueryParameters>
            <riaControls:Parameter ParameterName="UserLoginID" Value="{Binding Path=User.UserLoginID, Source={StaticResource WebContext}}" />
        </riaControls:DomainDataSource.QueryParameters>
    </riaControls:DomainDataSource>

The problem I'm experiencing is that whenever I log out, I get:

Load operation failed for query 'GetLogs'. Object reference not set to an instance of an object.

I assume that because I've logged out, User.UserLoginID is now null and is causing the exception.

So... anybody know a good way for me to solve this? I don't really want to set the QueryParameter programmatically.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about logout