Hi
I have created a simple .NET 6.0 application to convert an image to PDF.
For this I use Aspose.Drawing instead of System.Drawing.Common.
But when I run the application, I get an error: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly ‘System.Drawing.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’. The specified file cannot be found.
File name: ‘System.Drawing.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’
at Aspose.Imaging.Image.#=zdhS8Vtln7VSf(StreamContainer #=z9ROXOM6FvRVD, LoadOptions #=zYCOM1eZ$0uII)
at Aspose.Imaging.Image.Load(String filePath)
at Program.$(String[] args) in C:\Users\Yura\Documents\Visual Studio 2022\Projects\ConsoleApp1\ConsoleApp1\Program.cs:line 7
What have I done wrong?
If I use Aspose.PDF instead of Aspose.Imaging to insert images, then the error is the same.
using (var pdf = new Aspose.Pdf.Document())
{
using (var bitmap = new Bitmap(input))
{
ConsoleApp1.zip (25.1 KB)
@PoweRDeaD, Aspose.Imaging has version that supports Aspose.Drawing as default graphics engine it is available here NuGet Gallery | Aspose.Imaging 22.10.0-beta and you can try it. If your question is related to usage of Aspose.PDF with Aspose.Drawing you can ask this question in PDF related forum Aspose.PDF Product Family - Free Support Forum - aspose.com
1 Like
Ok.
If I use Aspose.Drawing and Aspose.Imaging in the same project:
<PackageReference Include="Aspose.Drawing" Version="22.11.0" />
<PackageReference Include="Aspose.Imaging" Version="22.10.0-beta" />
I get an error:
Aspose.Imaging.CoreExceptions.ImageLoadException: Image loading failed.
---> System.TypeInitializationException: The type initializer for 'Aspose.Imaging.ImageLoadersRegistry' threw an exception.
---> Aspose.Imaging.CoreExceptions.ImageLoadException: Error invocation Aspose.Imaging.InjectAsposeDrawing.Process
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeLoadException: Could not load type 'Skia.Core.Adapters.IImageFormatsProvider' from assembly 'Aspose.Drawing, Version=22.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'.
at Aspose.Imaging.InjectAsposeDrawing.Process()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at .☻(♣ ☻)
--- End of inner exception stack trace ---
at .☻(♣ ☻)
at Aspose.Imaging.ImageLoadersRegistry..cctor()
--- End of inner exception stack trace ---
at Aspose.Imaging.Image.☻(StreamContainer ☻, LoadOptions ♥)
--- End of inner exception stack trace ---
at Aspose.Imaging.Image.☻(StreamContainer ☻, LoadOptions ♥)
at Aspose.Imaging.Image.Load(String filePath)
at Program.<Main>$(String[] args) in C:\Users\Yura\Documents\Visual Studio 2022\Projects\ConsoleApp1\ConsoleApp1\Program.cs:line 20
Using ‘Aspose.Drawing’ version 22.6.0 helped me:
<PackageReference Include="Aspose.Drawing" Version="22.6.0" />
<PackageReference Include="Aspose.Imaging" Version="22.10.0-beta" />
@PoweRDeaD, thank you for information. Please note, that we have plans to release Aspose.Imaging for .NET7 in Apr-May 2023, which will contain Aspose.Drawing as default graphics engine.