The type specified in the TypeName property of ObjectDataSource ‘xx’ could not be found.

This one gets me every time, so I’m going to write it up in hopes that next time I search for it, I’ll find my own solution.

Situation: You’ve created a datasource in your .Net app, and want to use it on your report (RDLC). You create the report, point to the new Dataset, drop on some fields and run the report. Your heart drops because you get the error message:

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

Argh! How to solve this… you look at the source of a few other reports in XML to figure out what’s going on (Don’t forget to change that to your XSD Filename + underscore + TableAdapter name!) but that doesn’t solve the trick.

What you have to do is simple, but infuriating. Before you invoke your report in your code behind file, you have to set the TypeName property of the report. You can do this either in the on the ASPX file itself or by explicitly issuing it in code (which is what I like to do), like so:

String cXSD = "MyXSDFile"; // Name of your XSD file
String cDataSet = "MyDataSet"; // Name of your dataset within your XSD file
String cDataSource = cXSD+"_"+ cDataSet + "TableAdapter"; // eg. MyXSD_dsInvoiceTableAdapter
this.dsObject.TypeName = cXSD+ "TableAdapters." + cDataSet + "TableAdapter"; // eg MyXSDTableAdapters.dsInvoiceTableAdapter
this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource(cDataSource, this.dsObject));

Coming from a Visual Foxpro background, all of this seems like a huge PITA just to get some data to show on the screen. What do you think?


Posted

in

,

by

Tags:

Comments

One response to “The type specified in the TypeName property of ObjectDataSource ‘xx’ could not be found.”

  1. Eric Avatar

    Eric, be sure to read that 3rd paragraph!

    You must look at the source of a few other reports in the XML viewer and change the DataSetName! The default ‘DataSet1’ will not work.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.