[Mono-bugs] [Bug 675379] New: PackagePart.GetRelationships throws an "Operation not valid when package is read-only" exception when package is open with only read presmissions

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Feb 26 05:48:39 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=675379

https://bugzilla.novell.com/show_bug.cgi?id=675379#c0


           Summary: PackagePart.GetRelationships throws an "Operation not
                    valid when package is read-only" exception when
                    package is open with only read presmissions
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: agallero at netscape.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us)
AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4

When you open a System.IO.Packaging.Package with FileMode.Open and
FIleAccess.Read, you get a part of the package and try to get the part's
relationships, you get the error:
Operation not valid when package is read-only.





Reproducible: Always

Steps to Reproduce:
1.mcs -r:WindowsBase.dll Program.cs
2.mono Program.exe
Actual Results:  
Unhandled Exception: System.IO.IOException: Operation not valid when package is
read-only
  at System.IO.Packaging.Package.CheckIsReadOnly () [0x00000] in <filename
unknown>:0 
  at System.IO.Packaging.PackagePart.CreateRelationship (System.Uri targetUri,
TargetMode targetMode, System.String relationshipType, System.String id,
Boolean loading) [0x00000] in <filename unknown>:0 
  at System.IO.Packaging.PackagePart.LoadRelationships
(System.Collections.Generic.Dictionary`2 relationships, System.IO.Stream
stream) [0x00000] in <filename unknown>:0 
  at System.IO.Packaging.PackagePart.get_Relationships () [0x00000] in
<filename unknown>:0 
  at System.IO.Packaging.PackagePart.GetRelationships () [0x00000] in <filename
unknown>:0 
  at PackageOpenTest.Program.Main (System.String[] args) [0x00000] in <filename
unknown>:0 


Expected Results:  
No error.

Looks like "if (!loading)" is missing at the start of method
PackagePart.CreateRelationship

Changing
Package.CheckIsReadOnly ()
by

if (!loading){
                Package.CheckIsReadOnly ();
            }

And I also noticed Package.CreateRelationship() already does this.
PakagePart.CreateRelationship doesn't.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list