Page 1 of 1

NullReferenceExcpetion when reading from HPGL from stream

Posted: 19 Dec 2009, 00:39
by Dennis
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

Re: NullReferenceExcpetion when reading from HPGL from stream

Posted: 22 Dec 2009, 13:52
by support
Hello.
We will consider this problem.

Alexander.