Refactoring breaks ObjectDataSource

6 February 2008

After some major refactoring which involved namespace renaming I encountered the error "The type specified in the TypeName property of ObjectDataSource 'dsEntries' could not be found." on some pages where I use the ObjectDataSource control.

This is easy to fix by just changing the TypeName property to the new type, however I don't like the fact that my asp.net site compiles but still has these errors in it. So I moved the TypeName property from the aspx file to the Page_Load event in the codeBehind file. Rather than just using a string I use the following

dsEntries.TypeName = typeof(MyCompany.Project.Component.Directory.Entries).ToString();


Now this will no longer compile if I change the namespace, class or method names.

Declarative syntax is great but it has its drawbacks.

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows