Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do not give up and go to use DataSet! You are heading the right direction! Now, let's first take a look at the function signature:</p> <pre><code>DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) Error is “Invalid type owner for DynamicMethod" </code></pre> <p>The error message is trying to tell you, <code>Type owner</code> is not what the function is expecting. It wants a Class type. You are probably passing an Interface type into the <strong>Type owner</strong>. It is impossible to create dynamic methods on an Interface.</p> <p><strong>1.Error Example</strong></p> <p>Maybe you are using Dependency Injection, and you may like to use Interface.</p> <p>However, this code will hit Runtime Error.</p> <pre><code>var viewModelList = GetViewModels(); //returns an IList&lt;IViewModel&gt; &lt;-- has i !! var blv = new BindingListView&lt;IViewModel&gt;(viewModelList); </code></pre> <p><strong>2.Working Example</strong></p> <p>Try to redesign your code to use Concrete Type. </p> <p>Now, this code will NOT hit Runtime Error</p> <pre><code>var viewModelList = GetViewModels(); //returns an IList&lt;ViewModel&gt; &lt;-- has no i !! var blv = new BindingListView&lt;ViewModel&gt;(viewModelList); </code></pre> <p>Then, your Sorting and Filtering on <code>DataGridView</code> will work automagically :)</p> <p>EDIT ---------------------------------------------</p> <p>P.S. About trying to redesign your code:</p> <p>If you are using a MVVM/MVP pattern, think about the following logic. The <code>IList&lt;IViewModel&gt;</code> should stay on the "VM+P" side. Purpose of using IViewModel is mainly because I want to be able to replace it with, say, <code>MockingViewModel : IViewModel</code> for unit testing the "VM+P" side of logics. </p> <p>Now, the <code>BindingListView&lt;ViewModel&gt;</code> should really be on the "V" side, that is, the <code>YourView : System.Windows.Form { ... }</code>. And it will be binded to the binding source from there <code>YourBindingSource.DataSource = blv;</code> Since I won't be unit testing a WinForm, any logic in it I will try to refactor them into presenters and viewmodels and keep the View as thin as possible. So, I would just use ViewModel in BindingListView, not the interface IViewModel.</p> <p>So the <code>BindingListView&lt;ConcreteViewModel&gt;</code> will naturally make sense to me that it doesn't accept a model Interface.</p> <p>Refer to this question about MVVM MVP design and unit testing WinForm: <a href="https://stackoverflow.com/questions/1362814/should-i-unit-test-my-view-in-mvpor-vm-or-how-to-keep-the-code-in-the-view-to">Should I unit-test my view in MVP(or VM) or how to keep the code in the view to a minimum?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload