CADtoDWG.SaveAsDWG -> Exception Error

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Wahid Massan
Posts: 1
Joined: 26 Jan 2024, 18:22

CADtoDWG.SaveAsDWG -> Exception Error

Post by Wahid Massan » 26 Jan 2024, 18:36

I have written a small amount of test code to simply open a DWG file and then save it - Essentially making a copy. I wanted to ensure that I am not causing any issue by editting the file, so it's very simple:

Code: Select all

        void SaveFile()
        {
            CADImage cadImage = CADImage.CreateImageByExtension(selectFile.FileName);
            cadImage.LoadFromFile(selectFile.FileName);
            CADtoDWG.SaveAsDWG(cadImage, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "output.dwg"));
        }
I am using .NET (version 8.0) windows forms with CAD.NET 15.0.0.57290.

When I call this function, the following error is presented:
The type initializer for 'CADImport.Export.CADExportFrame' threw an exception.
It's a shame, because the library has some great tools - But I cannot save the file. Is there a known issue around saving .DWG files?

support
Posts: 3253
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADtoDWG.SaveAsDWG -> Exception Error

Post by support » 30 Jan 2024, 14:00

Wahid Massan wrote:
26 Jan 2024, 18:36
I have written a small amount of test code to simply open a DWG file and then save it - Essentially making a copy. I wanted to ensure that I am not causing any issue by editting the file, so it's very simple:

Code: Select all

        void SaveFile()
        {
            CADImage cadImage = CADImage.CreateImageByExtension(selectFile.FileName);
            cadImage.LoadFromFile(selectFile.FileName);
            CADtoDWG.SaveAsDWG(cadImage, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "output.dwg"));
        }
I am using .NET (version 8.0) windows forms with CAD.NET 15.0.0.57290.

When I call this function, the following error is presented:
The type initializer for 'CADImport.Export.CADExportFrame' threw an exception.
It's a shame, because the library has some great tools - But I cannot save the file. Is there a known issue around saving .DWG files?
Hi,
Unfortunately, this information is not enough to help you out, we need more details on the error. Is Cadimage null? What is your file extension? Does the external sgcadexp.dll library lie in the execution folder?
Please, try saving selected file in the Editor_NetCore demo. By the way, we released a newer CAD .NET version, that is available at https://cadsofttools.com/company/news/c ... -released/.
Also, I'd like to note that if an input file is raster then it will be saved as a raster image (not CADImage).

Best wishes,
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply