We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception in loading DXF

Hello, I’m using AsposeCad 22.3.0 for .NET to convert DXF to PDF.

This is my code:

string inputPath = @"C:\Users\john.doe\Desktop\testAspose\test2.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(inputPath))
{
	CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
	rasterizationOptions.UnitType = UnitType.Millimeter;
	rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;
	// output dimensions
	rasterizationOptions.PageWidth = 420;
	rasterizationOptions.PageHeight = 297;
	PdfOptions pdfOptions = new PdfOptions();
	pdfOptions.VectorRasterizationOptions = rasterizationOptions;
	image.Save(msOutput, pdfOptions);
}

I got an exception in the creation of Aspose.CAD.Image object. The exception message is:

ReflectionTypeLoadException: Unable to load one or more of the requested types.

I got the same exception with both the overloads of Aspose.CAD.Image.Load() method, path string or stream as parameter.
I got this exception with AsposeCad for .NET ver. 22.3.0 and 22.4.0. With ver 22.2.0 it was all fine.

My DXF input file here.
test2.zip (2.2 KB)

Please, fix it asap.
Regards.

@subGm,
Hello, could you please check whether this project works for you? What should we change to see the error? TestApp.zip (7.1 MB)

Hello, it works fine if I run your project.

In my project, with AsposeCad 22.4.0 I get an exception on
Aspose.CAD.Image image = Aspose.CAD.Image.Load(inputPath)

The inner exception message is:

Could not load file or assembly ‘System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. The located assembly’s manifest definition does not match the assembly reference. (0x80131040)

In case if it’s useful, my project’s target framework is .NET Standard 2.1

I solved by manually installing NuGet packages System.Text.Encoding.CodePages and System.Drawing.Common.
It’s weird that theis are not installed automatically as AsposeCad dependencies

@subGm,
it looks like sometimes this happens. I did not add any additional packages except of Aspose.CAD in the test project above and everything works. We will try to fix this in the next release. Anyway, we are happy that your problem is resolved.