DNG to image format in Unity

Hi,
I have to convert DGN and DWG files to an image format in the Unity software.

I downloaded Aspose.CAD and put the dll in the Unity Assets folder > System.Text.Json missing errors. I search around for this dll tried several but no luck.

Anyone knows how to fix this?
Thanks,
Raoul

@rtb.
Hello.
Could you please provide the screenshot with the error? What is the version of Aspose.CAD, what is .NET version? Could you please test if simple console project works separately?

Thank you for helping!

This is the full error in the Unity console:

Assembly ‘Assets/CADTest/lib/Aspose.CAD.dll’ will not be loaded due to errors:
Unable to resolve reference ‘System.Text.Json’. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

When disabling reference validation there are no errors but when doing a simple test (Convert DGN to BMP via C# | products.aspose.com)

A bunch of error like below are thrown:

ReflectionTypeLoadException: Exception of type ‘System.Reflection.ReflectionTypeLoadException’ was thrown.
Parent class vtable failed to initialize, due to: VTable setup of type Aspose.CAD.FileFormats.GLB.ExtraProperties failed assembly:D:\tmp\CAD Unity Project\Assets\CADTest\lib\Aspose.CAD.dll type:ExtraProperties member:(null)
Could not set up parent class, due to: VTable setup of type Aspose.CAD.FileFormats.GLB.ExtraProperties failed assembly:D:\tmp\CAD Unity Project\Assets\CADTest\lib\Aspose.CAD.dll type:ExtraProperties member:(null)
Could not set up parent class, due to: VTable setup of type Aspose.CAD.FileFormats.GLB.ExtraProperties failed assembly:D:\tmp\CAD Unity Project\Assets\CADTest\lib\Aspose.CAD.dll type:ExtraProperties member:(null)
Could not set up parent class, due to: VTable setup of type Aspose.CAD.FileFormats.GLB.ExtraProperties failed assembly:D:\tmp\CAD Unity Project\Assets\CADTest\lib\Aspose.CAD.dll type:ExtraProperties member:(null)
Could not set up parent class, due to: Could not set up parent class, due to: VTable setup of type Aspose.CAD.FileFormats.GLB.ExtraProperties failed assembly:D:\tmp\CAD Unity Project\Assets\CADTest\lib\Aspose.CAD.dll type:ExtraProperties member:(null) assembly:D:\tmp\CAD Unity Project\Assets\CADTest\lib\Aspose.CAD.dll type:#=z1pJWWav9gi58i1bI9cDsQWYM6HzepD5ogg== member:(null)

I have tried several .NET version, currently used: Unity 2022.38f1, API Compatability Level is set to “.NET Framework” in general, the other option is “.NET Standard 2.1” which I have also tried.

When adding the System.Text.Json dll manually I get a bunch of similar errors missing libraries.

When adding the Aspose.CAD dll to a project in Visual Studio Community and adding the code, the dll’s compile well without errors (code not tested!) This is the same project used to compile other dll’s used in a Unity project. The other dll’s work well in Unity untill I added the code from the link above.

Please let me know if you need more information.

@rtb,
OK, is the version of Aspose.CAD 23.10? Do you use the library from net462 folder? Can you create and zip here just empty Unity project so we can run it and observe the issue?

Yes, the downloaded zip extracts to “Aspose.CAD.23.10(dll_only)”
I am busy at the moment, but I will create an empty Unity project an upload here, is there an upload size restriction?

[Edit] And the net462 dll also results in the same problem, I will add this dll to the Unity project

@rtb,
yes, there is some restriction, feel free upload sample project to some file sharing service and post link here. Thank you.

Please find a Unity project here:

Unity 2022.3.8.f1. I removed the library file to reduce the size and checked the zip. The System.Text.Json error is still present.

@rtb,
Thank you. We will try to reproduce at our end, I will come back with more information.

Hi, I was wondering if you have you been able to look into this meanwhile?

Thank you.

@rtb,
Hi.
Could you please test this updated project (we have removed library).
UnityCADTest_fixed.zip (891.5 KB)

Thank you very much, it does import well now.

We will test further. So far a dwg file was converted well, we got a problem with a dgn file though, CadException: The Dgn version isn’t valid. Only Dgn: V7 are currently supported.

@rtb,
Unfortunately, we have support only for DGN V7.

I get this with a V7 file

StackOverflowException: The requested operation caused a stack overflow.
Aspose.CAD.FileFormats.Dgn.DgnElements.DgnCellHeaderElement…ctor (System.Byte[] #=zdIyThUg=, System.Boolean #=zc3_9KO5slA8f) (at <1107f7fadc6c45d1c7d7c3fbeecb4352>:0)

any idea what is causing this?

@rtb,
could you please attach the DGN file and the code that causes such behaviour?

I am afraid I cannot share this specific dgn file. I searched for other dgn files. I only found a few, I either get the only v7 supported message and for example this
e4.zip (4.2 KB)

It throws an ArgumentOutOfRangeException

Do you have/know a resource for free v7 DGN files to test just as a proof of concept?

@rtb,
I can see the issue with exporting of the attached file to PNG, we have created CADNET-9555 to investigate it. I don’t know about such resources, just searching for them, unfortinately.

@rtb,
the exception for this file is fixed for the latest Aspose.CAD for .NET 24.5. But the result is empty as there is no information available how these solids are stored inside the DGN format. The file contains only solids, so we can not support them and the result is empty.