This is a migrated thread and some comments may be shown as answers.

No target found for method AutoGeneratingColumn

2 Answers 213 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 09 Apr 2016, 07:49 PM

I'm running into a very odd problem that I am finding impossible to debug. I use customized column autogeneration of the RadGridView. Basically, on binding, it looks at each object that it is bound to and customizes the column based on attribute metadata decorating each property of the bound object. This all works fine.

In the app, I have a ComboBox which when a different item is selected, it changes the data source of the grid, clears the columns, and toggles the autogenerate property of the grid so that it generates columns based on the new data source. This code looks like this:

        private async void Grid_OnDataLoading(object sender, GridViewDataLoadingEventArgs e)
        {
            var grid = (RadGridView)sender;
            if (grid.AutoGenerateColumns != true) return;


            grid.Columns.RemoveItems(grid.Columns.Cast<GridViewColumn>().Where(c => c.GetType() != typeof(GridViewToggleRowDetailsColumn)).ToArray());
            grid.AutoGenerateColumns = false;
            grid.AutoGenerateColumns = true;  //Throws here
        }

This code works normally when the app first loads. It only throws when the ComboBox is toggled and the grid's source is changed. Even more bizarre, it used to work fine in all situations, but at some point some change was introduced to the codebase somewhere which is now producing a bizarre error.

On the call to grid.AutoGenerateColumns = true, it is now throwing an exception, saying "No target found for method AutoGeneratingColumn". And it is Calburn Micro throwing this error, which I have no idea why this would it would even be involved in this process.

Any advice on how to debug this further would be really appreciated, as I've spent a lot of time on it and am at a total loss. Thanks.

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Apr 2016, 01:49 PM
Hi Sam,

I can only be only guessing what the cause for this exception might be. I suggest you taking a look at the following StackOverflow threads, as a a similar issue has already been discussed in them.

-   wpf caliburn ComboBox OnSelectionChanged Event Exception
-   Cal.Message.Attach - No target found for method
-   No target found for method” thrown by Caliburn Message.Attach()
-   Caliburn with attached events, failing with target

I hope you find these resources helpful.

Regards,
Stefan X1
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Sam
Top achievements
Rank 1
answered on 13 Apr 2016, 03:42 PM
Thanks. It ended up being a bad Caliburn Attach to the OnAutoGeneratingColumn method. What is bizarre and made it so tough to track down was that it works correctly the first time the app loads, but then stops working. I changed the code to stop using Caliburn.Attach here and it fixed the issue.
Tags
GridView
Asked by
Sam
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Sam
Top achievements
Rank 1
Share this question
or