title: How to Analyze System.AccessViolationException on Unknown Module
body: <p>I have a MVC 4 project on Framework 4 with throws a System.AccessViolationException when you extend the HtmlHelper using <code>HtmlHelper.ViewContext.Writer</code></p>
  
  <p>The following code compiles just fine:</p>
  
  <pre><code>public static void Test(this System.Web.Mvc.HtmlHelper helper)
  {
      System.IO.TextWriter writer = helper.ViewContext.Writer;
      writer.WriteLine("&lt;b&gt;Test Output&lt;/b&gt;");
  }
  </code></pre>
  
  <p>But when I use it in the view it throws the error. Now I've confirmed the DLL that causes the problem, but I have no idea what to look for, because the error message is not helpful, not even a stack trace. The thing is the project was a MVC3 project written on VS2010, now that I updated to VS2013 and tried to upgrade to MVC4 the problem started, but the weird thing is that when I used the same DLL on other MVC4 projects in VS2010 on Framework 4, then it worked, now when I made a clean MVC4 project on Framework 4 this happens.</p>
  
  <p>I know that the DLL in question is causing the problem and I do have the source code for it, but I have no idea what to look for.</p>
  
  <p>I did test other extending methods and for example this works just fine:</p>
  
  <pre><code>public static System.Web.Mvc.MvcHtmlString Test(this System.Web.Mvc.HtmlHelper helper)
  {
      return new System.Web.Mvc.MvcHtmlString("&lt;b&gt;Test Output&lt;/b&gt;");
  }
  </code></pre>
  
  <p>So it has to do something with the <code>ViewContext</code> of the <code>HtmlHelper</code>, but what?</p>
  
  <p>The easiest thing would be to simply change the extending method, but do to company policy I'm not allowed to do that so I need to figure this out.</p>
  
  <p>My biggest issue is that the DLL in question is not really written by me and only my computer has VS2013, so any direction would be helpful i.e. what to look for or anything like that.</p>