Free Support Forum - aspose.com

Console.SetOut

I found this out through a lot of painful debugging. This is an FYI. I have found a way around it.

If you have the following (roughly):

using(var sw = new StreamWriter('test"))
{
Console.SetOut(sw);
}

Aspose.Slides will fail on simple code like this:

public async void SimpleAsposeTest()
{
using (var pres = new PresentationEx(@“C:\temp\Optum_MARKUP.pptx”))
{
pres.Save(@“c:\temp\demoDefault.pdf”, SaveFormat.Pdf);
}
}

The Exception is:

Cannot Write to Closed TextWriter

My guess is that Aspose.Slides has Console statements inside of it that cause it to fail.

Hi Alan,


I have observed your requirement and it seems you are using legacy API on your end. I suggest you to please try using Aspose.Slides for .NET 15.2.0 on your end first. If there is still an issue then please share the sample project with us reproducing the issue and I will investigate it further on my end to help you out.

Many Thanks,

I did. Same issue is in there.

It does not happen in PPTX or HTML, only PDF. A developer has left in a Console.Debug/Write/Read in the code or else uses it w/o seeing if the Console has been redirected.

Hi Alan,


Thank you for sharing the information. As requested earlier, please first try using Aspose.Slides for .NET 15.2.0 on your end. If you are still able to reproduce the issue then please provide the working sample project and source presentation reproducing the issue on your end. I will be able to commence my investigation once the requested information will be shared to help you further.

Many Thanks,

That is what I said, I did use the latest and I saw the same thing.

Please use the sample code I shared and make the very minor changes for v15 and you will see the same behavior.

My code is working so this is merely an FYI for Aspose so you don’t have to have it reported again.

Hi Alan,

I have shared the sample project for your kind reference that I have generated using Aspose.Slides for .NET 15.2.0. I have not been able to observe the issue. I request you to please share another sample and source presentation if you are unable to reproduce the issue with my sample code.

Many Thanks,

Attaching project showing error. I downloaded latest Slides yesterday.

Execute w/o Error first then with Error.

Hi Alan,


Thank you for sharing the sample project. I have worked with that on my end and have not been able to observe any issue on my end. The only difference on your end and my end is different log and presentation files. Please also share the log and presentation files so that I may try reproducing it on my end.

Many Thanks,

Win7, 64-bit.

PPTX is attached, Log should be created on the fly.

EDIT: I added a new version that does logging. Here is the log I receive:

Step Before Initialization
Step After Initialization
Step Before Presentation NoError
Step Before Save of Presentation
Step After Save of Presentation
Step Before Error StreamWriter
Step Before Console.SetOut
Step After Console.SetOut
Step Before Presentation Error
Step Before Save of PDF
Step EXCEPTION: System.ObjectDisposedException: Cannot write to a closed TextWriter.
at System.IO.__Error.WriterClosed()
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(Char[] buffer)
at System.IO.TextWriter.WriteLine()
at System.IO.TextWriter.SyncTextWriter.WriteLine()
at System.Console.WriteLine()
at .(BitmapData , Boolean )
at .(Boolean , Boolean )
at .( ​ )
at .(Byte[] )
at …ctor( , ​ )
at .( ​ , )
at .( ​ )
at .( ​ , Boolean )
at .( )
at . ( )
at . ( )
at . ( )
at . ( )
at . ( )
at . ( )
at .( )
at .(Presentation , Stream , Int32[] , PdfOptions , ISaveOptions )
at .(Presentation , Stream , PdfOptions , ISaveOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at TestAsposeError.MainWindow.ButtonError_Click(Object sender, RoutedEventArgs e) in c:\temp\TestAsposeError\TestAsposeError\MainWindow.xaml.cs:line 56


Hi Alan,

I have worked with the presentation file shared by you and this time I have been able to reproduce the issue. An issue with ID SLIDESNET-36351 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-36351) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.