SkiaSharp.QrCode: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.

If i build this for linux, i get the error: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. Exception:

 ---> System.DllNotFoundException: Unable to load DLL 'libSkiaSharp' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKImageInfo..ctor(Int32 width, Int32 height)
   at AT.QRCoder.DiscordBot.Commands.QrCoder.GenerateQr(String content, String darkColor, String lightColor, String iconUrl) in C:\Users\Name\Desktop\ProjName\src\Proj.ProjName\Commands\File.cs:line 30```

at this line:
 ` var info = new SKImageInfo(660, 660);`

Do you know what causes that and how to fix that? 

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (14 by maintainers)

Most upvoted comments

I still get the same error using the following package references:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Discord.Net" Version="2.2.0" />
    <PackageReference Include="Discord.Net.Core" Version="2.2.0" />
    <PackageReference Include="SkiaSharp" Version="2.80.2" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.2" />
    <PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" />
  </ItemGroup>

</Project>

Thanks for the reply, these are my package references:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Discord.Net" Version="2.2.0" />
    <PackageReference Include="Discord.Net.Core" Version="2.2.0" />
    <PackageReference Include="SkiaSharp" Version="2.80.2" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2" />
    <PackageReference Include="SkiaSharp.QrCode" Version="0.4.0" />
  </ItemGroup>

</Project>```

Unfourtunately it doesnt work. 

no update? let’s close issue.

A Dockerfile I’ve pushed to your repo was FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base, Debian 10 env and it runs successfully.

@AlexGipp Sorry I was down for these days, Let me check tonight.

thank you, I will check it later.

@AlexGipp Can you try with following package?

update: I’ve released 0.4.1. Please use 0.4.1 and SkiaSharp.NativeAssets.Linux.NoDependencies if you have no dependencies to fonts.

  <ItemGroup>
    <PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.2" />
  </ItemGroup>

In your case,

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Discord.Net" Version="2.2.0" />
    <PackageReference Include="Discord.Net.Core" Version="2.2.0" />
    <PackageReference Include="SkiaSharp" Version="2.80.2" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.2" />
    <PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" />
  </ItemGroup>

</Project>