Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# aws lambda dll reference issues

I am trying to publish an image resizing aws lambda function (written in c# for .net core v1.0) from vs2017. I have tried several third party libraries compatible with .net core (Magick.net and SkiaSharp). However, when executing the function, I am running into System.DllNotFoundException, saying the DLL for the library cannot be found. At first, I thought my issues were specific to the library being used, but I get this error regardless of library used.

Any thoughts? Maybe there is something special I need to do in visual studio to get the dll to upload to amazon?

Example error: System.DllNotFoundException: Unable to load DLL 'libSkiaSharp': The specified module could not be found.

If I can't use a third party image resizing library for c# aws lambda functions, then are there .net core resizing functions available (since system.drawing is only avail on windows, and aws runs on linux)

I get the error on first instance of using a function in the referenced DLLs. Example for SkiaSharp:

using SkiaSharp;

using (var objectResponse = await S3Client.GetObjectAsync(s3Event.Bucket.Name, s3Event.Object.Key))
{
   // THROWS THE DLL FOUND FOUND EXCEPTION
   using (var original = SKBitmap.Decode(objectResponse.ResponseStream))  
   {
   }
}
like image 251
Ash Avatar asked Feb 18 '26 04:02

Ash


1 Answers

I actually solved the issue myself. Instead of referencing the SkiaSharp library directly, I'm now referencing a linux wrapper for it (https://www.nuget.org/packages/Avalonia.Skia.Linux.Natives) Now the dll is bundled with the deployment package

like image 166
Ash Avatar answered Feb 19 '26 16:02

Ash