代码之家  ›  专栏  ›  技术社区  ›  KSK

.NET标准2.0项目无法加载dapper 1.50.5

  •  2
  • KSK  · 技术社区  · 6 年前

    我刚开始使用.NET标准。在一个概念验证项目中,我试图使用dapper作为我的ORM。在.NET标准2.0类库项目中,我添加了dapper 1.50.5 nuget包。但是,运行时未加载程序集。 我得到这个错误:

    System.IO.FileNotFoundException   HResult=0x80070002
    Message=Could not load file or assembly 'Dapper, Version=1.50.5.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    The system cannot find the file specified.
    

    .csproj的完整内容:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
      </PropertyGroup>
      <ItemGroup>
        <PackageReference Include="Dapper" Version="1.50.5" />
        <PackageReference Include="Npgsql" Version="4.0.4" />
        <PackageReference Include="System.Data.SqlClient" Version="4.6.0" />
        <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
        <PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
        <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
        <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" />
      </ItemGroup>
    </Project>
    

    所以,您可以看到我已经安装了依赖项和依赖项。

    我还应该做什么?

    1 回复  |  直到 6 年前
        1
  •  1
  •   KSK    6 年前

    https://github.com/dotnet/sdk/issues/901

    1. <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
      <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
      

    Yes... I used Notepad.