1

Closed

dxf = DxfDocument.Load() returns Null

description

Hi,

I have a very weird problem with DxfDocument.Load().

It is working fine most of the time loading a DXF file from the file opening dialog.

But for some drawings, such as the attached file, which is a very simple drawing with just a circle and a few arcs, the function returns Null, which create exceptions when trying to process the dxf object later on.

What is more weird, with that DXF file, using the same software I wrote, the software installed on one particular machine also fails at first (returns Null upon calling the function) but after several tries it works as it should. On all the other machine, it just doesn't work.

I am not sure its a problem with the library or Windows.

Any help is greatly appreciated.

This is my code:
            try
            {
                if (openFileDialog2.ShowDialog() == DialogResult.Cancel) return;
                if (!File.Exists(openFileDialog2.FileName)) return;
                Refresh();
                dxf = DxfDocument.Load(openFileDialog2.FileName);
                panelCanvas.Invalidate(); //clear the canvas
                isFileLoaded = true;
            }
            catch (Exception err)
            {
                MessageBox.Show("Error opening file: " + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //List major types of supported objects in the file
            lblLines.Text = dxf.Lines.Count.ToString();
UPDATE: I TRIED THE DEBUG BUILD OF THE LIBRARY AND IT IS WORKING FINE, ALSO NO EXCEPTIONS ARE CAUGHT. WHAT COULD BE THE ISSUE?

file attachments

Closed May 11 at 6:37 PM by haplokuon

comments

mariocaptain wrote Mar 1 at 7:01 AM

Please note that the try ... catch didn't catch any exception opening the file.

Dave

haplokuon wrote Mar 3 at 5:26 PM

I have not been able to reproduce your problem, your file loads just fine, and I have not seen any thing strange that might generate an error. Are you using multiple threads by any chance?

I cannot think of anything that might make the release build failing to load a file, while the debug build works fine. You can try the source code to see if it changes something.

Daniel