[Mono-dev] creating excel files

eng. Ahmed Youssef ahhatem at gmail.com
Mon Feb 28 08:55:11 EST 2011


But it doesn't behave this way under .net.
It doesn't dispose the stream.

On Mon, Feb 28, 2011 at 3:26 PM, Rafael Teixeira <monoman at gmail.com> wrote:

> That is the documented (expected) behavior of Close:
>
> "Saves and closes the package plus all underlying part streams."
> See
> http://msdn.microsoft.com/en-us/library/system.io.packaging.package.close.aspx
>
> And that is a common pattern in all reader/writer classes in .NET.
>
> Hope it clarifies it all,
>
> Rafael "Monoman" Teixeira
> ---------------------------------------
> "The most exciting phrase to hear in science, the one that heralds new
> discoveries, is not 'Eureka!' (I found it!) but 'That's funny ...'"
> Isaac Asimov
> US science fiction novelist & scholar (1920 - 1992)
>
>
>
> On Sat, Feb 26, 2011 at 9:04 AM, eng. Ahmed Youssef <ahhatem at gmail.com>wrote:
>
>> Hello everyone,
>>
>> Sorry for the late reply but I thought I do my homework first...
>>
>> After moving to mono 2.10 on opensuse, I managed to make the library work
>> on mono.
>> The problem was with this scenario:
>>
>> using System;
>> using System.IO.Packaging;
>> using System.IO;
>>
>> namespace test
>> {
>> class MainClass
>>  {
>> public static void Main (string[] args)
>> {
>>  MemoryStream stream = new MemoryStream ();
>> Package p = Package.Open (stream, FileMode.Create, FileAccess.ReadWrite);
>>  p.Close ();
>> stream.ReadByte();
>>  }
>> }
>> }
>>
>> throws this exception:
>>
>> Unhandled Exception: System.ObjectDisposedException: The object was used
>> after being disposed.
>>   at System.IO.MemoryStream.CheckIfClosedThrowDisposed () [0x00000] in
>> /usr/src/packages/BUILD/mono-2.10/mcs/class/corlib/System.IO/MemoryStream.cs:133
>>   at System.IO.MemoryStream.ReadByte () [0x00000] in
>> /usr/src/packages/BUILD/mono-2.10/mcs/class/corlib/System.IO/MemoryStream.cs:261
>>   at test.MainClass.Main (System.String[] args) [0x00000] in <filename
>> unknown>:0
>>
>>
>> the package.Close call internally makes this:
>>
>> public void Close()
>> {
>> this.Flush();
>> this.Dispose(1);
>> }
>>
>> for some reason the dispose call disposes the stream too....
>>
>> After replacing the package.Close() with package.Flush().... the EPPlus
>> lib works nicely....
>>
>> I hope that is useful... I don't mind digging into the issue more but I am
>> not sure how to do that.... any info would be appreciated.
>> I hope you confirm that it is a mono issue and that it will be fixed so
>> that either mono is fixed or the library...
>>
>> Thank you all for the help.
>>
>>
>> On Tue, Feb 22, 2011 at 7:11 PM, jmalcolm <malcolm.justin at gmail.com>wrote:
>>
>>>
>>> I am not sure how big the spreadsheets are that you need to work with but
>>> I
>>> have used the free version of GemBox to great effect:
>>>
>>> http://www.gemboxsoftware.com/GBSpreadsheetFree.htm
>>> --
>>> View this message in context:
>>> http://mono.1490590.n4.nabble.com/creating-excel-files-tp3315324p3319632.html
>>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>>
>>
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110228/bdac4eb3/attachment.html 


More information about the Mono-devel-list mailing list