Efcore: System.TypeLoadException: Could not load type 'System.Diagnostics.CodeAnalysis.MaybeNullAttribute' from assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

Created on 8 Sep 2019  路  17Comments  路  Source: dotnet/efcore

Maybe U ve reopen this issue.
https://github.com/aspnet/EntityFrameworkCore/issues/17081
I have Same problem with
Microsoft.EntityFrameworkCore" Version="3.0.0-preview9.19423.6

image

this my project file


<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview9.19424.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
  </ItemGroup>


  <ItemGroup>
    <ProjectReference Include="..\EntityCodeGen\EntityCodeGen.csproj" />
  </ItemGroup>

</Project>

closed-question customer-reported

Most helpful comment

@Diaskhan correct. Before we closed #17081 we found that a more recent SDK was needed because of the changes to the attributes. Please confirm if after upgrading to the Preview 9 SDK you still see the problem.

All 17 comments

Same error here

And here i'm afraid

@Diaskhan, @gianmarcorosso can you please both confirm what exact versions of the .NET Core SDK and the EF Core 3.0 package you have been using?

There was some last minute churn in the attribute types for nullable reference types, so this could either be caused by using mismatched versions of the package and the SDK or by a bug, for example if the version o .NET Standard isn't up to date.

@terrajobst do you know of any reason this could be happening?

cc @roji

@ian-witz likewise, what is the exact version of the SDK and EF Core packages you are using?

dotnet --info

.NET Core SDKs installed:
3.0.100-preview5-011568 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Main project

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview9.19424.4" />
    <PackageReference Include="Microsoft.CodeAnalysis" Version="3.3.1-beta3-final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\EntityCodeGen\EntityCodeGen.csproj" />
  </ItemGroup>
</Project>

Standart library

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <AssemblyName>1</AssemblyName>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis" Version="3.3.1-beta3-final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview9.19423.6">
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview9.19423.6" />
    <PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
  </ItemGroup>
</Project>


Upgrade to last Sdk (SDK 3.0.100-preview9-014004)?

upgraded from preview 7 to preview 9 and the issue appears to have gone away; another issue has arisen but that's probably in my code! thanks.

@Diaskhan correct. Before we closed #17081 we found that a more recent SDK was needed because of the changes to the attributes. Please confirm if after upgrading to the Preview 9 SDK you still see the problem.

1 Min

After Updating to the dotnet-sdk-3.0.100-preview9-014004-win-x64.exe
problem solves! Closing Issue!
@divega Great Thank U!

Thanks for confirming @Diaskhan!

I know. Need For another googlers))

Xamarin.Android 10.0.99.100 has the same issue.
Can you please reopen this issue and if possible create a new Xamarin.Android version where this works?
@divega do you know if there is a workaround in the meantime? (other than downgrading again)

Edit: Xamarin.Android 10.0.0.43 is broken as well

Could u provide more information ?
What version of skd u using ?
dotnet-sdk-3.0.100-preview9-014004-win-x64.exe

Hey all, I resolved mine the following way :

  • Make sure all .net core runtimes and SDKs are uninstalled. Run dotnet --info to see. If installing 3.0.100 didnt remove the previews, go to those dirs and manually remove them. Re install (modify) the net core 3.0.100 installation to be safe again.

  • Make sure you have installed VS 2019 16.3.1

Error should disappear.

I've been using SDK 3.0.100 ( 2019-09-23) which is more recent than SDK 3.0.100-preview9-014004 (2019-09-04)
I'm also using the latest pre-release of VS2019 which uses Xamarin.Android 10.0.99.100
Tested with non pre-release VS2019 which uses Xamarin.Android 10.0.0.43

Though it don't think the SDK makes any difference for the Android build, AFAIK the netstandard.dll is supplied by Xamarin.Android and not by the SDK for Android right?

Better its to create new ticket and provide full information ! Because its another case ! U cold referenced to this ticket !

Was this page helpful?
0 / 5 - 0 ratings