No target found for method AutoGeneratingColumn

3 posts, 0 answers
  1. Sam
    Sam avatar
    17 posts
    Member since:
    Feb 2012

    Posted 09 Apr 2016 Link to this post

    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. Stefan
    Stefan avatar
    1073 posts

    Posted 13 Apr 2016 Link to this post

    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.

    Stefan X1
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. Sam
    Sam avatar
    17 posts
    Member since:
    Feb 2012

    Posted 13 Apr 2016 in reply to Sam Link to this post

    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.
Back to Top