dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] ResourceWriter constructor throws unjustified exceptio


From: Bruno Haible
Subject: [Pnet-developers] ResourceWriter constructor throws unjustified exception
Date: Mon, 29 Dec 2003 12:39:30 +0100
User-agent: KMail/1.5

Using pnet-0.6.0.

Trying to create a .resources file through ResourceWriter fails if the
file already exists, although it is writable. Neither "resgen", nor
"monoresgen", nor the ResourceWriter in Mono have this behaviour.

=============================== hello.cs ========================
using System;
using System.Resources;
class Hello {
  static void Main () {
    ResourceWriter rw = new ResourceWriter("foo.resources");
    rw.AddResource("Simple", "Einfach");
    rw.Generate();
    rw.Close();
  }
}
==================================================================

$ cscc hello.cs -o hello.exe
$ touch foo.resources
$ ls -l foo.resources 
-rw-r--r--    1 bruno    user            0 2003-12-28 16:19 foo.resources
$ ilrun hello.exe
Uncaught exception: System.IO.IOException: Operation not permitted
        at System.IO.FileStream..ctor(String, FileMode, FileAccess, FileShare, 
Int32, Boolean) in ./System/IO/FileStream.cs
        at System.IO.FileStream..ctor(String, FileMode, FileAccess)
        at System.Resources.ResourceWriter..ctor(String)
        at Hello.Main()

$ mono hello.exe
; OK

The fix would be to use FileMode.Create instead of FileMode.CreateNew in the
ResourceWriter(String) constructor in
runtime/System/Resources/ResourceWriter.cs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]