NullReferenceExcpetion when reading from HPGL from stream
Moderators: SDS, support, admin
NullReferenceExcpetion when reading from HPGL from stream
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:
The following is what I like to do but causes the NullReferenceExcpetion:
I tried the following as well without success:
Any advice would be gratefully appreciated,
Dennis
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);
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
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
Dennis
Re: NullReferenceExcpetion when reading from HPGL from stream
Hello.
We will consider this problem.
Alexander.
We will consider this problem.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support