title: .NET 4.6 required for .NET 4.5.2 compiled application
body: <p>After upgrading from building our product in Visual Studio 2010 and .NET 4.0 to Visual Studio 2015 and .NET 4.5.2 we have seen issues running the product on a customers machine.</p>
  
  <p>The error we see is a <code>System.MissingMethodException</code> being thrown when starting the application, which from looking at posts on here point to an incorrect version of .NET being installed on the machine. Now the customers machine does have .NET 4.5.2 installed as this is installed during the installation of our product.</p>
  
  <p>The way we have currently fixed the issue is to install .NET 4.6 on the customers machine.</p>
  
  <p>I have a theory that I ideally want to confirm (well preferably rubbish and replace with something more viable):</p>
  
  <ul>
  <li>All of our projects are set to compile against <strong>.NET 4.5.2</strong></li>
  <li>The build agent that compiles the code and generates the installer has Visual Studio 2015 and with it <strong>.NET 4.6</strong> but it does have the necessary .NET 4.5.2 framework installed</li>
  </ul>
  
  <p>I believe that because .NET 4.6 is installed the machine it is overriding the .NET 4.5.2. I don't know why this would be happening but I have seen something vaguely similar where a .NET 4.0 application running on a machine with .NET 4.5 installed behaves how a .NET 4.5 application would <a href="https://connect.microsoft.com/VisualStudio/feedback/details/811420/net-4-5-1-framework-update-breaks-existing-idataerrorinfo-implementation-in-net-4-0-application" rel="nofollow">here</a> (if it is I am pretty sure it shouldn't be). I was hoping someone might be able to point out something that I am missing.</p>
  
  <p>I do hope that my theory is wrong.</p>
  
  <p><strong>Additional Information</strong></p>
  
  <p>I have managed to attach a debugger when the application crashes and the error is:</p>
  
  <blockquote>
    <p>Method not found: '!!0[] System.Array.Empty()'.</p>
  </blockquote>
  
  <p>There is nothing in my code that uses Array.Empty().</p>
  
  <p>StackTrace:</p>
  
  <blockquote>
    <p>at MyApp.DisplayExceptionInfo(Exception ex)<br>
      at MyApp.Main(String[] args) in E:\Build\MyApp\App.xaml.cs:line 82</p>
  </blockquote>
  
  <p><code>DisplayExceptionInfo</code> simply tries to display an Exception which makes me believe that an Exception is being thrown earlier.<br>
  <code>Main</code> checks to see if there is another instance running through some Interop (which I also tried removing but it did not resolve the crash) and then creates my App class and runs it.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Sorry I don't believe I gave enough details in my question to help get to the bottom of the issue. It turns out that TeamCity uses MSBuild to build Visual Studio solutions and during the build there is the following warning (annoyingly rather well buried in the log):</p>
  
  <blockquote>
    <p>[GetReferenceAssemblyPaths] C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1097, 5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.</p>
  </blockquote>
  
  <p>I can confirm that I do have the .NET 4.5.2 Multi-Targeting Pack installed but I will continue to investigate</p>