Hey,

I'm creating a web application with the use of a ObjectDataSource. When I try to run the webapp i get the following error:

The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found.

[InvalidOperationException: The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found.]
   System.Web.UI.WebControls.ObjectDataSourceView.GetType(String typeName) +1122339
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1171
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +19
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

It seems that the ObjectDataSource can not find the object I use. But I Assure you, it is there. The Object is created in the App_Code folder and is completely tested without the ObjectDataSource object.

I referr to this object like this.

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataTable" 
            TypeName="namespace.theObject"></asp:ObjectDataSource>
        <br />
        <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1">
        </asp:GridView>

I hope anyone can tell me what I am doing wrong.

Dani AI

Generated

The exception means ASP.NET could not load the CLR type named in the ObjectDataSource TypeName. As discovered, a very common cause is hosting the site as a virtual directory instead of an IIS application: App_Code is only treated as application-level code when the folder is an IIS application root, so types inside it will not be compiled or visible otherwise.

  • Convert the virtual directory to an application in IIS Manager (right‑click the folder -> Convert to Application / Add Application) and assign an app pool with the correct .NET CLR.
  • Verify the class is public and that TypeName exactly matches the full namespace + class name (spellings and case matter).
  • If the type lives in a separate assembly, put the DLL in the web app’s bin folder (or use an assembly-qualified name) so the runtime can load it.
  • Ensure the method referenced by SelectMethod is public. If it is an instance method the class needs a public parameterless constructor (or make the method static).
  • Recycle the app pool or touch web.config to force a recompile so App_Code changes take effect.

Also note the project model: Web Site projects rely on App_Code, while Web Application projects expect compiled code in bin. ’s remark about a missing/mismatched TypeName is still relevant — once the folder is an application, the namespace/class spelling is the usual remaining culprit.

Recommended Answers

All 2 Replies

Parameter's property TypeName is missing or somewhat it uses different class name which is not available in your application.

I have figured it out. I was running the webpage as Virtual Directory. I needed to use an application

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.