SharePoint

Posts   
 
    
Posts: 2
Joined: 21-Nov-2006
# Posted on: 21-Nov-2006 13:00:09   

LLBLGenPro version number : 2.0.0.61023

I created a custom control which simply displays records in a gridview getting the data from LLBLGenPro. It works fine in a normal ASP.NET website, but in Sharepoint i get the following error : Object reference not set to an instance of an object

Stack trace :

[NullReferenceException: Object reference not set to an instance of an object.]
   SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceBase.OnDataSourceUnload(Object sender, EventArgs e) +67
   System.Web.UI.Control.OnUnload(EventArgs e) +2065500
   System.Web.UI.Control.UnloadRecursive(Boolean dispose) +267
   System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
   System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
   System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
   System.Web.UI.Page.UnloadRecursive(Boolean dispose) +20
   System.Web.UI.Page.ProcessRequestCleanup() +40
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.usercontrols_default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a031ab73\fcffb215\App_Web_default.aspx.6bb32623.69vrsatu.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Here is my web.config file (at least the first part of it...)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
    <configSections>
        <sectionGroup name="SharePoint">
            <section name="SafeControls" type="Microsoft.SharePoint.ApplicationRuntime.SafeControlsConfigurationHandler, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
            <section name="RuntimeFilter" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <section name="WebPartLimits" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <section name="WebPartCache" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <section name="WebPartWorkItem" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <section name="WebPartControls" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <section name="SafeMode" type="Microsoft.SharePoint.ApplicationRuntime.SafeModeConfigurationHandler, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
            <section name="MergedActions" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <section name="PeoplePickerWildcards" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </sectionGroup>
        <sectionGroup name="System.Workflow.ComponentModel.WorkflowCompiler" type="System.Workflow.ComponentModel.Compiler.WorkflowCompilerConfigurationSectionGroup, System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <section name="authorizedTypes" type="System.Workflow.ComponentModel.Compiler.AuthorizedTypesSectionHandler, System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </sectionGroup>
        <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </configSections>
    <sqlServerCatalogNameOverwrites>
        <add key="DigiOffice_Schema" value="DigiOfficeNET"/>
        <!-- LLBLGen Pro Catalog name overwriting -->
    </sqlServerCatalogNameOverwrites>
    <connectionStrings>
        <add name="DigiOffice" connectionString="Data Source=*********;Initial Catalog=DigiOfficeNET;User ID=**********;Password=**************" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <appSettings>
        <add key="Main.ConnectionString" value="Data Source=********;Initial Catalog=DigiOfficeNET;User ID=*******;Password=*********"/>
        <add key="SqlServerDQECompatibilityLevel" value="1"/>
        <!-- LLBLGen Pro DQE compatibility mode -->
    </appSettings>

I copied all the dll files in the bin directory of this website. And here is the design of the control

<%@ Control Language="C#" AutoEventWireup="true" Inherits="WebApplication8.Personen" %>

<%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses"
    TagPrefix="llblgenpro" %>
    
<llblgenpro:LLBLGenProDataSource ID="dsPersonen" runat="server" DataContainerType="EntityCollection" EntityCollectionTypeName="PersoonCollection, IDB.DigiOffice.DAO" CacheLocation="Session" EnablePaging="True">
</llblgenpro:LLBLGenProDataSource>

<asp:GridView id="gvPersonen" runat="server" datasourceid="dsPersonen"
    AutoGenerateColumns="true" GridLines="None" AllowPaging="true" AllowSorting="true" >
    <EmptyDataTemplate>
        No records dude
    </EmptyDataTemplate>
</asp:GridView>

When I use a 'normal' SqlDataSource like

<asp:SqlDataSource ID="dsPersonen" runat="server" connectionstring="..." selectCommand="select * from personen" />

all goes perfect, so it has to do something with LLBLGenPro.

But I'm lost. What am I missingconfused Does anybody have a clue??

Thanks in advance

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 21-Nov-2006 14:08:07   

This is the routine:


/// <summary>
/// Called when [data source unload].
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void OnDataSourceUnload( object sender, EventArgs e )
{
    if( !DesignMode )
    {
        switch( _cacheLocation )
        {
            case DataSourceCacheLocation.ViewState:
                // do nothing, is already handled
                break;
            case DataSourceCacheLocation.Session:
                // save to session
                this.Context.Session[_dataStorageKey] = CreateStateDataObject();
                break;
        }
        // dispose a loaded view, as it contains a live adapter
        GetView().Dispose();
    }
}

So I can only think of one thing: that there's no session object. Getview() creates or returns the current datasourceview object. It always returns an object.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 2
Joined: 21-Nov-2006
# Posted on: 21-Nov-2006 15:19:26   

The way I got it fixed, is by modifying the web.config file and add the session to the httpModules section. <add name="Session" type="System.Web.SessionState.SessionStateModule"/>


<system.web>
    <httpModules>
        <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
        ...
    </httpModules>
    ...
</system.web>

Thanks for the quick response Otis !!