4

I am working on an ASP.NET page with a GridView and an ObjectDataSource.

I want to configure the ObjectDataSource against a class (decorated with DataObject()) in my business layer. A class amongst many others set up in a very similar fashion. I selected the class and clicked Next to pick the function for the SelectMethod andbut it closes without warning and without any error.

I can set the TypeName for the ObjectDataSource and attach it to a GridView. I attempted to Refresh Schema and I got an error pop up:

Error invoking 'Refresh Schema'. Details: Exception has been thrown by the target of an invocation.

I can manually set up the ObjectDataSource, but I am inherently lazy and would prefer to use the GUI.

Why is it failing?

Everything builds just fine. I can manually hook everything up and the page works just fine. Yet it still fails when I go to configure the ObjectDataSource with the UI.

Raghav
  • 570
  • 1
  • 13
  • 24
BlackMael
  • 3,198
  • 5
  • 25
  • 42

1 Answers1

0

The ODS control has some prerequisites in order to work properly and will throw that generic Exception has been thrown by the target of an invocation. if some of these configurations are not correct. Here are a few things to try to fix the problem:

  1. The class that is bound to an ODS control must have a default empty constructor that does not take any parameters. It is fine to overload it, but there must at least be a default empty constructor; make sure this exists.

  2. The ODS can get out of whack from its bound class if that class exists within another project that is referenced by your UI project that contains the ODS. Make sure to fully clean and re-build the solution so the current class schema can be read by the ODS wizzard.

  3. Try deleting the ODS (save off any customized properties from the IDS in source to notepad to add back in item-by-item later) and adding on a new one. Once the new ODS is added, use the Wizzard to point to the class you want and see if it works.

Nix
  • 57,072
  • 29
  • 149
  • 198
atconway
  • 20,624
  • 30
  • 159
  • 229