MissingMethodException: Aspose.Words.DocumentBuilder.InsertImage

Recently, when working with Aspose.Words 18.10.0, I am seeing:

System.MissingMethodException: 'Method not found: 'Aspose.Words.Drawing.Shape Aspose.Words.DocumentBuilder.InsertImage(SkiaSharp.SKBitmap, Double, Double)'.'

on my machine and on my UAT server, but not on my Azure service when calling a method which contains the above mentioned InsertImage call.

I’m referencing SkiaSharp 1.60.1 in the project, and it is in the bin folder. This previously used to work, but I think i had moved some files manually into the bin folder but did a clean and they were removed.

I’ve tried multiple versions of SkiaSharp and all appear to do the same.

@Brian.Mahocker The only thing I can suspect is that you mistakenly referenced Aspose.Words .NET dll instead of .NET Standard dll. I would suggest you to remove reference to Aspose.Words and to SkiaSharp and then add reference to Aspose.Words from NuGet. It should select the right dll for your application.
If this does not help, please create a simple application that will allow us to reproduce the problem and attach it here.

@alexey.noskov To add some more detail (that I probably should have before), Project A is a .net 4.7 winforms apps which references Project B which is a standard 2.0 project. Project B is the one that references Aspose.Words and SkiaSharp; Project A does not contain any direct references to either.

I’ll create a smaller example project in the meantime, but would that be part of the problem?

@Brian.Mahocker Thank you for additional information. It would be great if you create a simple solution that will allow us to reproduce the problem. It sounds like NuGet improperly resolved the reference to Aspose.Words, but it is difficult to say without a sample application.

FormGenerator.zip (7.0 MB)

Sorry for the delay. Minimum project is attached. I’m referencing Aspose.Words 18.10.0, which I didn’t include for size reasons and SkiaSharp 1.60.1

Thank you for additional information. I checked your project and see that you reference Aspose.Words from both ManualInterfaceUI and FormGenerator projects, which it redundant. It is required to add reference to Aspose.Words only from FormGenerator project. Also, it is not required to separately add reference to SkiaSharp, NuGet automatically resolves package dependencies.
In addition, please add the following section into FormGenerator.csproj

  <PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>

Good to know that; that got me halfway there.

I also needed to copy libskiasharp from Project B’s packages folder to Project A’s bin folder. but all appears to be good. Thanks.

@Brian.Mahocker Yes libskiasharp is required to be copied if you deploy your application to Linux. It is perfect that you managed to resolve your problem. Please feel free to ask in case of any further issues.

Could you please share how you achieved to copy libskiasharp from projetct B to Project A ? I have the same issue

By that, I mean I manually copied the libskiasharp dll from the bin folder of project A to the bin folder of project B, since project B needed it, but it wasn’t being copied automatically

@nanoxi Please try to specify Runtime Identifier while publishing:

dotnet publish -r win-x64

in this case libskiasharp must be published into the target folder.

Thanks. I am still encountering issues with PDF and SkiaSharp in a .net standard 2.0 library referenced in a .net 4.7.2 console application. I will prepare a sample project to illustrate the issues.

@nanoxi Sure we will wait for your inputs. Why do you use .NET Standard 2.0 version of Aspose.Words in .net 4.7.2 project. You can use .NETFramework 4.6.1 version of Aspose.Words, which uses System.Drawing to deal with graphics.