title: The model item passed into the dictionary is of type 'MyType', but this dictionary requires a model item of type 'MyType'
body: <p>Yes, I went through the questions with similar titles. None of them seem to match the situation I'm in. It's simply the programmer sending a wrong object type to the view.</p>
  
  <p>This is the exact error message I'm receiving: </p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'IS.Extensions.Models.ContactSelectList', but this dictionary requires a model item of type 'IS.Extensions.Models.ContactSelectList'.</p>
  </blockquote>
  
  <p>I started moving around views and model classes in our solution in an attempt to make it 'framework-like'. With this I mean that some views/models we have are used in multiple MVC applications and some views/models are specific for a certain MVC application.<br>
  The issue started áfter moving the ContactSelectList view.<br>
  Common views are in a project that uses the <a href="http://razorgenerator.codeplex.com/" rel="nofollow noreferrer">Razor generator</a> to compile them.</p>
  
  <p>I have this in my view:  </p>
  
  <pre><code>@model IS.Extensions.Models.ContactSelectList
  </code></pre>
  
  <p>and when debugging I can see that the model I'm sending to the RenderPartial method is of THE SAME TYPE:
  <img src="https://i.stack.imgur.com/50yQN.png" alt="enter image description here"></p>
  
  <p>Some sidenotes:</p>
  
  <ul>
  <li>IS is a MVC web app and references IS.Extensions</li>
  <li>IS.Extensions is a class library referenced by IS</li>
  <li>ContactSelectList.cshtml is located in IS\Views\Controls</li>
  <li>The ContactSelectList.cs model class is located in IS.Extensions\Models</li>
  <li>The 'parent view' (the view that triggers this RenderPartial call is situated in the 'common' project: ZModel.Web\Views\Controls</li>
  </ul>
  
  <p>Does anyone have any idea what's going on here? The error messages is kinda confusing and not really a help..</p>
  
  <p><strong>Edit after Erics comment:</strong>  </p>
  
  <p>The assembly containing the model class (ContactSelectList.cs) is dynamically loaded. Why? Because I thought it makes sense to create a kind of extension / plugin system, where dropping a certain dll in a certain directory extends the common models with some application specific ones.<br>
  This is how (slightly modified):</p>
  
  <pre><code>var zExtenderAssembly = Assembly.LoadFile(path);
  extenderType = zExtenderAssembly.GetTypes().ToList().Where(t =&gt; t.GetInterface("IZExtender") != null).FirstOrDefault();
  return (Activator.CreateInstance(extenderType) as IZExtender).CreateBO("ContactSelectList");
  </code></pre>
  
  <p>The 'CreateBo' method in the ZExtender (implements IZExtender) simply creates a new instance of a ContactSelectList (which is in the same library as the ZExtender, so no reflection needed):  </p>
  
  <pre><code>public Component CreateBO(string name)
  {
      ...
              return new ContactSelectList();
      ...
  }
  </code></pre>