May 9, 2008

MOSS: The type specified in the TypeName property of ObjectDataSource could not be found.

When using ObjectDataSource in Web Part and you only have your Assembly in GAC, you'll might see the following error:

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

You init the ObjectDataSource in your Web Part e.g., like this:

ObjectDataSource ods = new ObjectDataSource("Namespace.Class", "SomeMethod");
ods.ID = "myOds";

Add reference to the assembly in web.config like this (where MyAssemblyName is the name of the assembly of your Web Part).

<add assembly="MyAssemblyName, Version=XYZ, Culture=neutral, PublicKeyToken=XYZ" />


  1. Did the error occassionally occur, or constant?
    And do you also have the assemblies registered in the safecontrols-section of web.config?

    Reason for asking is that I have this exact error in a custom user-control which is loaded using a webpart (not smartpart, but something similar), which occassionally pops up (about 20 times a day with 200 users)...

  2. In my case the error was constant and having the assembly in the SafeControls section didn't have any effect.

    Just a thought (you've probably already done this), if you have multiple WFEs, it's a good idea to double-check that all WFEs are configured in the same way (e.g., identical SafeControls entries in web.config).

  3. Single WFE and sometimes the error pops up. Do you by any change know what the difference is between the SafeControls-section and the Assemblies-section in the web.config?

    I have my assemblies registered under safecontrols, and located in both the bin and GAC.

  4. You can also use the next formula:

    TypeName="#namespace + className#, #Dll Name#, Version=#Dll version#, Culture=#Dll culture#, PublicKeyToken=#Dll publickeytoken"

  5. Hello,

    I have a user control that uses ObjectDataSource to bind to business data. The user control project is build seperately and it gets copied to my webpart project GAC, and I used LoadControl to in my webpart code. After deploying, I still get Type "The type specified in the TypeName property of ObjectDataSource ...not found, even though I have included both dlls (user control and webpart) in safecontrol and <assemblies sectiion of web.config. Does any one knows what I am doing wrong, please help...thanks in advance.