May 9, 2008

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

Problem:
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";
this.Controls.Add(ods);

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

<system.web>
<compilation>
<assemblies>
<add assembly="MyAssemblyName, Version=XYZ, Culture=neutral, PublicKeyToken=XYZ" />
</assemblies>
</compilation>
</system.web>