title: Why does my Azure Functions project not recognize classes from Microsoft.AspNetCore.Http assembly?
body: <p>I have an Azure Functions project targeting <code>netcoreapp3.1</code>. The project references another Class Library project (also targeting <code>netcoreapp3.1</code>) that uses the <code>FormFile</code> class from the <a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Http/" rel="nofollow noreferrer"><code>Microsoft.AspNetCore.Http</code></a> assembly.</p>
  
  <p>The Class Library project compiles and tests run through the code successfully but when I run the Azure Functions project I get the following exception:</p>
  
  <blockquote>
    <p>System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.Internal.FormFile' from assembly 'Microsoft.AspNetCore.Http, Version=3.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.</p>
  </blockquote>
  
  <p><strong>My question is</strong> why is the azure functions project unable to load the class and how can I fix it?</p>
  
  <hr>
  
  <p>Here is the project file for the Azure Functions project:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp3.1&lt;/TargetFramework&gt;
      &lt;AzureFunctionsVersion&gt;v3&lt;/AzureFunctionsVersion&gt;
      &lt;AssemblyName&gt;AzureFunctionsProject&lt;/AssemblyName&gt;
      &lt;RootNamespace&gt;AzureFunctionsProject&lt;/RootNamespace&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid" Version="3.0.0" /&gt;
      &lt;PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.3" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="3.0.1" /&gt;
      &lt;PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;ProjectReference Include="..\ClassLibraryProject.csproj" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;None Update="host.json"&gt;
        &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
      &lt;/None&gt;
      &lt;None Update="local.settings.json"&gt;
        &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
        &lt;CopyToPublishDirectory&gt;Never&lt;/CopyToPublishDirectory&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>And the project file for the Class Library:
  ClassLibraryProject</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp3.1&lt;/TargetFramework&gt;
      &lt;AssemblyName&gt;ClassLibraryProject&lt;/AssemblyName&gt;
      &lt;RootNamespace&gt;ClassLibraryProject&lt;/RootNamespace&gt;
      &lt;LangVersion&gt;8.0&lt;/LangVersion&gt;
      &lt;Nullable&gt;enable&lt;/Nullable&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;None Include="..\.editorconfig" Link=".editorconfig" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Azure.Storage.Blobs" Version="12.4.1" /&gt;
      &lt;PackageReference Include="Dapper" Version="2.0.35" /&gt;
      &lt;PackageReference Include="Dapper.Contrib" Version="2.0.35" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" /&gt;
      &lt;PackageReference Include="Microsoft.Azure.ServiceBus" Version="4.1.3" /&gt;
      &lt;PackageReference Include="Microsoft.Data.SqlClient" Version="1.0.19269.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>Running <code>dotnet --list-runtimes</code> outputs:</p>
  
  <pre><code>Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  </code></pre>