Re: security permissions for creating a file
- From: "Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com>
- Date: Wed, 3 Aug 2005 07:43:52 -0400
"Mark" <Scollop027@xxxxxxx> wrote in message
news:dcpobo$pvt$00$1@xxxxxxxxxxxxxxxxxxxx
> hi,
>
> what I am trying:
>
> 1. I create a file x.cs with notepad nothing more than a main
<snip>
> 2. built it with csc.exe x.cs and got a x.exe
> 3. executing x.exe on commandline (local dir, no shares, as admin, no
> domain, simple way)
If you're running the exe from a local hard drive (as opposed to somewhere
on your network), it sounds like you might have modified your CAS policy.
To verify what permissions your executable is being assigned under your
current CAS policy, follow the steps listed in the "How can I test my policy
changes?" section at
http://msdn.microsoft.com/library/en-us/dnnetsec/html/entsecpoladmin.asp.
If your assembly is local, and it's granted anything other than an
unrestricted permission set, your CAS policy has been modified from its
default configuration.
If you are running with modified policy, was it a deliberate change or not?
If it wasn't deliberate, you might want to simply revert to the default
configuration (after backing up your current configuration). If it was
deliberate, then adding a new code group to allow your application to run as
desired might be a better approach.
If your assembly is granted unrestricted permissions under policy, might the
problem stem from use of assembly-level permissions attributes? In
particular, might you be using any attributes with
SecurityAction.RequestOptional?
> 4. got exception - I guess .NET told me that this application is not safe
> writing files.
> Request for the permission of type
> System.Security.Permissions.FileIOPermission, mscorlib,
> Version=1.0.5000.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
>
> regards
> Mark
>
> "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> schrieb
> im Newsbeitrag news:e2ysb93lFHA.2080@xxxxxxxxxxxxxxxxxxxxxxx
>> Are you sure that the security exception is for opening the file
>> then?
>> Where is the application loaded from? Are you running it from a network
>> share, or the internet? If so, then the application is going to be
> granted
>> a limited permission set.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>> "Mark" <Scollop027@xxxxxxx> wrote in message
>> news:dco6ob$ig6$01$1@xxxxxxxxxxxxxxxxxxxx
>> > Hi Nicholas,
>> >
>> > I tried a console application and as admin I have no restriction in any
>> > directory.
>> >
>> > regards Mark
>> >
>> >
>> >
>> > "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> schrieb
>> > im Newsbeitrag news:eszHSt3lFHA.3256@xxxxxxxxxxxxxxxxxxxxxxx
>> >> Mark,
>> >>
>> >> You get this exception because you don't have rights to create or
>> >> open
>> >> the file in the directory that it is set in. You need to try and
> create
>> > the
>> >> file in a directory that you have rights to, or, if the file exists,
>> >> check
>> >> the rights on the file to make sure that you can open it for writing.
>> >>
>> >> Hope this helps.
>> >>
>> >>
>> >> --
>> >> - Nicholas Paldino [.NET/C# MVP]
>> >> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>> >>
>> >> "Mark" <Scollop027@xxxxxxx> wrote in message
>> >> news:dco3i4$btq$01$1@xxxxxxxxxxxxxxxxxxxx
>> >> > Hello,
>> >> >
>> >> > in a simple console application I try to create a file with some
>> >> > code
>> >> > like:
>> >> >
>> >> > FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
>> >> > FileAccess.Write);
>> >> > StreamWriter sw = new StreamWriter(file);
>> >> > sw.Write("Hello");
>> >> > sw.Close();
>> >> > file.Close();
>> >> >
>> >> > I will get an error System.Security.SecurityException
>> >> >
>> >> > Are there only one way to avoid this and how this can be done?
>> >> >
>> >> > Thanks and regards
>> >> > Mark
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
.
- References:
- security permissions for creating a file
- From: Mark
- Re: security permissions for creating a file
- From: Nicholas Paldino [.NET/C# MVP]
- Re: security permissions for creating a file
- From: Mark
- Re: security permissions for creating a file
- From: Nicholas Paldino [.NET/C# MVP]
- Re: security permissions for creating a file
- From: Mark
- security permissions for creating a file
- Prev by Date: Re: Composite properties to my control
- Next by Date: Re: security permissions for creating a file
- Previous by thread: Re: security permissions for creating a file
- Next by thread: Re: security permissions for creating a file
- Index(es):
Relevant Pages
|