NullReferenceExcpetion when reading from HPGL from stream

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Dennis
Posts: 1
Joined: 19 Dec 2009, 00:14

NullReferenceExcpetion when reading from HPGL from stream

Post by Dennis » 19 Dec 2009, 00:39

Hi there,
I can read a HPGL file using LoadFromFile without any problems, but as soon as I use LoadFromStream I receive a NullReferenceException in a method called from LoadFromStream accepting 1 stream argument. I can not see the name in the stacktrace ;-(

The following code works fine for me:

Code: Select all

 StreamWriter hpglFile = File.CreateText(plotFilename);
hpglFile.Write(plotfileContent);
hpglFile.Flush();
hpglFile.Close();

CADImage cadImage = CADImage.CreateImageByExtension(plotFilename);
CADImage.CodePage = System.Text.Encoding.UTF8.CodePage;
CADImage.LastLoadedFilePath = Path.GetDirectoryName(plotFilename);
cadImage.LoadFromFile(plotFilename);
The following is what I like to do but causes the NullReferenceExcpetion:

Code: Select all

CADImage cadImage = new CADImport.HPGL2.HPGLImage();
Encoding encoder = new ASCIIEncoding();
byte[] plotCharacters = encoder.GetBytes(plotfileContent);
MemoryStream plotMemoryStream = new MemoryStream(plotCharacters, false);

Stream plotReaderStream = plotMemoryStream;

CADImage.CodePage = encoder.CodePage;
cadImage.LoadFromStream(plotReaderStream); // <== NullReferenceException occurs here in a call to a methode accepting a Stream
I tried the following as well without success:

Code: Select all

 CADImage cadImage = new CADImport.HPGL2.HPGLImage();
FileStream plotFileStream = File.OpenRead(plotFilename);

Stream plotReaderStream = plotFileStream;

cadImage.LoadFromStream(plotReaderStream); // <== NullReferenceException occurs here in a call to a methode accepting a Stream
Any advice would be gratefully appreciated,
Dennis

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

Re: NullReferenceExcpetion when reading from HPGL from stream

Post by support » 22 Dec 2009, 13:52

Hello.
We will consider this problem.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply