none
LINQ DataSource ContextTypeName - Could not load type for context type RRS feed

  • Question

  • I have a SharePoint server that I am writing custom web parts for. I have custom controls that are loaded by the webpart at runtime using:

    Page.LoadControl("ViewAll.ascx");

     

    I've setup LINQ and can run queries directly in the code but when I try to use the LinqDataSource control I get the following exception:

     

    [HttpException (0x80004005): Could not load type 'MechanicalDesign.Database.MechanicalDesignDataContext'.]
       System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +8819397
       System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +93

    [InvalidOperationException: Could not find the type specified in the ContextTypeName property of LinqDataSource 'LinqDataSource1'.]
       System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +209
       System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTable(DataSourceOperation operation) +680
       System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTableForSelect() +91
       System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +383

    The .ascx file looks like this:

    <%@ Control Language="C#" AutoEventWireup="true" Inherits="MechanicalDesign.ViewAll, MechanicalDesign, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" %>

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <asp:LinqDataSource ID="LinqDataSource1" runat="server"

    ContextTypeName="MechanicalDesign.Database.MechanicalDesignDataContext"

    TableName="Logs">

    </asp:LinqDataSource>

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"

    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="id"

    DataSourceID="LinqDataSource1">

    <Columns>

    <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True"

    SortExpression="id" />

    <asp:BoundField DataField="taskId" HeaderText="taskId"

    SortExpression="taskId" />

    <asp:BoundField DataField="taskRevId" HeaderText="taskRevId"

    SortExpression="taskRevId" />

    <asp:BoundField DataField="actionId" HeaderText="actionId"

    SortExpression="actionId" />

    <asp:BoundField DataField="user" HeaderText="user" SortExpression="user" />

    <asp:BoundField DataField="type" HeaderText="type" SortExpression="type" />

    <asp:BoundField DataField="message" HeaderText="message"

    SortExpression="message" />

    <asp:BoundField DataField="timestamp" HeaderText="timestamp"

    SortExpression="timestamp" />

    </Columns>

    </asp:GridView>

    Thursday, December 4, 2008 9:14 PM

Answers

  • Got it!

    I needed to use the full name of the data context type.

     

    e.g.

     

    "MechanicalDesign.Database.MechanicalDesignDataContext, MechanicalDesign, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"
    Thursday, December 4, 2008 9:39 PM

All replies

  • Got it!

    I needed to use the full name of the data context type.

     

    e.g.

     

    "MechanicalDesign.Database.MechanicalDesignDataContext, MechanicalDesign, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"
    Thursday, December 4, 2008 9:39 PM
  • How do you find the full name?


    Jesse Myer Enterprise IT Architect

    Wednesday, February 22, 2012 5:23 AM