FileIOPermission Erro using referenced dll on shared hosting

Discussion in 'ASP .Net' started by brian@norman.org, May 30, 2006.

  1. Guest

    Hello

    I get this error when trying to create a file:

    Exception Details: System.Security.SecurityException: Request for the
    permission of type 'System.Security.Permissions.FileIOPermission,
    mscorlib, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089' failed.

    The code that causes this error is in a seperate dll (in the bin
    directory) to the webapp that is referenced and called to do various
    things by the main web apps.

    Exactly the same code works on other non-shared servers but on my new
    hosting companies shared servers it errors.

    I did have to remove one line of the web config:

    <identity impersonate="false"/>

    Otherwise the website would not even run complaining about not being
    able to override the web hosts default value for this.

    Ive checked the file is within the applications directory and have
    tested creating the same file from a normal aspx page in the webapp and
    that works fine so its specifically from the referenced dll.

    Ive tried running the same code under .net 1.1 and .net 2. .net1.1
    complains when creating the file, .net 2.0 complains when creating the
    directory for the new file.

    Anyone got any ideas? Id like to try it under full trust but my host
    won't let me even to test if this is the issue.

    Brian Norman
    , May 30, 2006
    #1
    1. Advertising

  2. parshu Guest

    Brian this seems like an permission issue. ASPNET account doesn't seem
    to be having a write permission for that specific directory. You need
    to increase the access right to the directory in order to make this
    work.

    HTH

    wrote:
    > Hello
    >
    > I get this error when trying to create a file:
    >
    > Exception Details: System.Security.SecurityException: Request for the
    > permission of type 'System.Security.Permissions.FileIOPermission,
    > mscorlib, Version=2.0.0.0, Culture=neutral,
    > PublicKeyToken=b77a5c561934e089' failed.
    >
    > The code that causes this error is in a seperate dll (in the bin
    > directory) to the webapp that is referenced and called to do various
    > things by the main web apps.
    >
    > Exactly the same code works on other non-shared servers but on my new
    > hosting companies shared servers it errors.
    >
    > I did have to remove one line of the web config:
    >
    > <identity impersonate="false"/>
    >
    > Otherwise the website would not even run complaining about not being
    > able to override the web hosts default value for this.
    >
    > Ive checked the file is within the applications directory and have
    > tested creating the same file from a normal aspx page in the webapp and
    > that works fine so its specifically from the referenced dll.
    >
    > Ive tried running the same code under .net 1.1 and .net 2. .net1.1
    > complains when creating the file, .net 2.0 complains when creating the
    > directory for the new file.
    >
    > Anyone got any ideas? Id like to try it under full trust but my host
    > won't let me even to test if this is the issue.
    >
    > Brian Norman
    parshu, May 31, 2006
    #2
    1. Advertising

  3. I can't reproduce the problem at the medium trust level. Might your hosting
    provider be willing to share the details of the CAS permission grant for
    your application? Is there anything about the DLL that might cause it to be
    granted a different set of permissions than the rest of the application?
    Also, could you please post the details of how you are attempting to create
    the file as well as it's exact relative path within your application
    directory?


    <> wrote in message
    news:...
    > Hello
    >
    > I get this error when trying to create a file:
    >
    > Exception Details: System.Security.SecurityException: Request for the
    > permission of type 'System.Security.Permissions.FileIOPermission,
    > mscorlib, Version=2.0.0.0, Culture=neutral,
    > PublicKeyToken=b77a5c561934e089' failed.
    >
    > The code that causes this error is in a seperate dll (in the bin
    > directory) to the webapp that is referenced and called to do various
    > things by the main web apps.
    >
    > Exactly the same code works on other non-shared servers but on my new
    > hosting companies shared servers it errors.
    >
    > I did have to remove one line of the web config:
    >
    > <identity impersonate="false"/>
    >
    > Otherwise the website would not even run complaining about not being
    > able to override the web hosts default value for this.
    >
    > Ive checked the file is within the applications directory and have
    > tested creating the same file from a normal aspx page in the webapp and
    > that works fine so its specifically from the referenced dll.
    >
    > Ive tried running the same code under .net 1.1 and .net 2. .net1.1
    > complains when creating the file, .net 2.0 complains when creating the
    > directory for the new file.
    >
    > Anyone got any ideas? Id like to try it under full trust but my host
    > won't let me even to test if this is the issue.
    >
    > Brian Norman
    >
    Nicole Calinoiu, May 31, 2006
    #3
  4. Guest

    Ok stupid as the solution is here is what was happing

    The code was for an open source wiki called perspective, which I guess
    no one has ever used on shared hosting.

    In one of the project function libraries the author was for some reason
    creating directories using FileSystemObject using the
    WindowsScriptingComponent via interop?

    So I replaced this with the .net Directory.CreateDiretory and it all
    worked.

    I guess you cannot use WindowsScriptingComponent , or at least to write
    directories, using medium trust.

    Thanks for all your suggestions anyway
    Brian
    , May 31, 2006
    #4
  5. Calling into COM objects requires SecurityPermission\Unmanaged code, which
    is not part of the medium trust level grant. It's a "dangerous" permission
    that is not granted at any of the ASP.NET trust levels other than full
    trust.


    <> wrote in message
    news:...
    > Ok stupid as the solution is here is what was happing
    >
    > The code was for an open source wiki called perspective, which I guess
    > no one has ever used on shared hosting.
    >
    > In one of the project function libraries the author was for some reason
    > creating directories using FileSystemObject using the
    > WindowsScriptingComponent via interop?
    >
    > So I replaced this with the .net Directory.CreateDiretory and it all
    > worked.
    >
    > I guess you cannot use WindowsScriptingComponent , or at least to write
    > directories, using medium trust.
    >
    > Thanks for all your suggestions anyway
    > Brian
    >
    Nicole Calinoiu, May 31, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?cGF1bA==?=

    System.Security.Permissions.FileIOPermission

    =?Utf-8?B?cGF1bA==?=, Oct 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    952
    =?Utf-8?B?cGF1bA==?=
    Oct 1, 2004
  2. Nalaka

    random FileIOPermission error

    Nalaka, Aug 1, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    511
    Walter Wang [MSFT]
    Aug 17, 2006
  3. Carl Gilbert
    Replies:
    0
    Views:
    457
    Carl Gilbert
    Oct 4, 2006
  4. Dave

    FileIOPermission Help

    Dave, Oct 18, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    404
  5. teo1991
    Replies:
    0
    Views:
    556
    teo1991
    Apr 2, 2009
Loading...

Share This Page