System.Security.Permissions.FileIOPermission

Discussion in 'ASP .Net Security' started by Simon Cheng, Nov 25, 2005.

  1. Simon Cheng

    Simon Cheng Guest

    Hi,

    I am getting the following error when trying to read an XML file. Is there
    some setting in web.config or machine.config that needs to be set?

    Thanks,
    - Simon

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Security Exception
    Description: The application attempted to perform an operation not allowed
    by the security policy. To grant this application the required permission
    please contact your system administrator or change the application's trust
    level in the configuration file.

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

    Source Error:

    Line 9: string strXmlFileName = @".\Sample.xml";
    Line 10: DataSet dsBasic = new DataSet();
    Line 11: dsBasic.ReadXml(strXmlFileName);
    Line 12:

    Source File: e:\default.aspx Line: 11

    Stack Trace:

    [SecurityException: Request for the permission of type
    System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.]
    System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
    grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
    PermissionToken permToken) +675
    System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken,
    CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames,
    Int32 unrestrictedOverride) +0
    System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap,
    StackCrawlMark& stackMark) +88
    System.Security.CodeAccessPermission.Demand() +62
    System.IO.Path.GetFullPath(String path) +90
    System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri) +599
    System.Xml.XmlTextReader..ctor(String url, XmlNameTable nt) +91
    System.Xml.XmlTextReader..ctor(String url) +65
    System.Data.DataSet.ReadXml(String fileName) +48
    ASP.default_aspx.Page_Load(Object Sender, EventArgs e) in
    e:\content\winisp\paihungchen\paihungchen.members.winisp.net\default.aspx:11
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +2112
    System.Web.UI.Page.ProcessRequest() +218
    System.Web.UI.Page.ProcessRequest(HttpContext context) +18
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
    +179
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    completedSynchronously) +87
     
    Simon Cheng, Nov 25, 2005
    #1
    1. Advertising

  2. Hello Simon,

    seems you are running in partial trust. Is this a hosted environment?

    ---------------------------------------
    Dominick Baier - DevelopMentor
    http://www.leastprivilege.com

    > Hi,
    >
    > I am getting the following error when trying to read an XML file. Is
    > there some setting in web.config or machine.config that needs to be
    > set?
    >
    > Thanks,
    > - Simon
    > Server Error in '/' Application.
    > ----------------------------------------------------------------------
    > ----------
    > Security Exception
    > Description: The application attempted to perform an operation not
    > allowed
    > by the security policy. To grant this application the required
    > permission
    > please contact your system administrator or change the application's
    > trust
    > level in the configuration file.
    > Exception Details: System.Security.SecurityException: Request for the
    > permission of type System.Security.Permissions.FileIOPermission,
    > mscorlib, Version=1.0.5000.0, Culture=neutral,
    > PublicKeyToken=b77a5c561934e089 failed.
    >
    > Source Error:
    >
    > Line 9: string strXmlFileName = @".\Sample.xml";
    > Line 10: DataSet dsBasic = new DataSet();
    > Line 11: dsBasic.ReadXml(strXmlFileName);
    > Line 12:
    > Source File: e:\default.aspx Line: 11
    >
    > Stack Trace:
    >
    > [SecurityException: Request for the permission of type
    > System.Security.Permissions.FileIOPermission, mscorlib,
    > Version=1.0.5000.0,
    > Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.]
    > System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
    > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
    > PermissionToken permToken) +675
    > System.Security.CodeAccessSecurityEngine.Check(PermissionToken
    > permToken,
    > CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
    > checkFrames,
    > Int32 unrestrictedOverride) +0
    > System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
    > cap,
    > StackCrawlMark& stackMark) +88
    > System.Security.CodeAccessPermission.Demand() +62
    > System.IO.Path.GetFullPath(String path) +90
    > System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
    > +599
    > System.Xml.XmlTextReader..ctor(String url, XmlNameTable nt) +91
    > System.Xml.XmlTextReader..ctor(String url) +65
    > System.Data.DataSet.ReadXml(String fileName) +48
    > ASP.default_aspx.Page_Load(Object Sender, EventArgs e) in
    > e:\content\winisp\paihungchen\paihungchen.members.winisp.net\default.a
    > spx:11
    > System.Web.UI.Control.OnLoad(EventArgs e) +67
    > System.Web.UI.Control.LoadRecursive() +35
    > System.Web.UI.Page.ProcessRequestMain() +2112
    > System.Web.UI.Page.ProcessRequest() +218
    > System.Web.UI.Page.ProcessRequest(HttpContext context) +18
    >
    > System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecut
    > ionStep.Execute()
    > +179
    > System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    > Boolean&
    > completedSynchronously) +87
     
    Dominick Baier [DevelopMentor], Nov 25, 2005
    #2
    1. Advertising

  3. Simon Cheng

    Simon Cheng Guest

    Yes.

    "Dominick Baier [DevelopMentor]" <>
    wrote in message news:...
    > Hello Simon,
    >
    > seems you are running in partial trust. Is this a hosted environment?
    >
    > ---------------------------------------
    > Dominick Baier - DevelopMentor
    > http://www.leastprivilege.com
    >
    >> Hi,
    >>
    >> I am getting the following error when trying to read an XML file. Is
    >> there some setting in web.config or machine.config that needs to be
    >> set?
    >>
    >> Thanks,
    >> - Simon
    >> Server Error in '/' Application.
    >> ----------------------------------------------------------------------
    >> ----------
    >> Security Exception
    >> Description: The application attempted to perform an operation not
    >> allowed
    >> by the security policy. To grant this application the required
    >> permission
    >> please contact your system administrator or change the application's
    >> trust
    >> level in the configuration file.
    >> Exception Details: System.Security.SecurityException: Request for the
    >> permission of type System.Security.Permissions.FileIOPermission,
    >> mscorlib, Version=1.0.5000.0, Culture=neutral,
    >> PublicKeyToken=b77a5c561934e089 failed.
    >>
    >> Source Error:
    >>
    >> Line 9: string strXmlFileName = @".\Sample.xml";
    >> Line 10: DataSet dsBasic = new DataSet();
    >> Line 11: dsBasic.ReadXml(strXmlFileName);
    >> Line 12:
    >> Source File: e:\default.aspx Line: 11
    >>
    >> Stack Trace:
    >>
    >> [SecurityException: Request for the permission of type
    >> System.Security.Permissions.FileIOPermission, mscorlib,
    >> Version=1.0.5000.0,
    >> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.]
    >> System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
    >> grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
    >> PermissionToken permToken) +675
    >> System.Security.CodeAccessSecurityEngine.Check(PermissionToken
    >> permToken,
    >> CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
    >> checkFrames,
    >> Int32 unrestrictedOverride) +0
    >> System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
    >> cap,
    >> StackCrawlMark& stackMark) +88
    >> System.Security.CodeAccessPermission.Demand() +62
    >> System.IO.Path.GetFullPath(String path) +90
    >> System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
    >> +599
    >> System.Xml.XmlTextReader..ctor(String url, XmlNameTable nt) +91
    >> System.Xml.XmlTextReader..ctor(String url) +65
    >> System.Data.DataSet.ReadXml(String fileName) +48
    >> ASP.default_aspx.Page_Load(Object Sender, EventArgs e) in
    >> e:\content\winisp\paihungchen\paihungchen.members.winisp.net\default.a
    >> spx:11
    >> System.Web.UI.Control.OnLoad(EventArgs e) +67
    >> System.Web.UI.Control.LoadRecursive() +35
    >> System.Web.UI.Page.ProcessRequestMain() +2112
    >> System.Web.UI.Page.ProcessRequest() +218
    >> System.Web.UI.Page.ProcessRequest(HttpContext context) +18
    >>
    >> System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecut
    >> ionStep.Execute()
    >> +179
    >> System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    >> Boolean&
    >> completedSynchronously) +87

    >
    >
     
    Simon Cheng, Nov 25, 2005
    #3
  4. Hello Simon,

    then you have to contact your provider to get the policy settings - seems
    you are not allowed to read files...

    ---------------------------------------
    Dominick Baier - DevelopMentor
    http://www.leastprivilege.com

    > Yes.
    >
    > "Dominick Baier [DevelopMentor]"
    > <> wrote in message
    > news:...
    >
    >> Hello Simon,
    >>
    >> seems you are running in partial trust. Is this a hosted environment?
    >>
    >> ---------------------------------------
    >> Dominick Baier - DevelopMentor
    >> http://www.leastprivilege.com
    >>> Hi,
    >>>
    >>> I am getting the following error when trying to read an XML file. Is
    >>> there some setting in web.config or machine.config that needs to be
    >>> set?
    >>>
    >>> Thanks,
    >>> - Simon
    >>> Server Error in '/' Application.
    >>> --------------------------------------------------------------------
    >>> --
    >>> ----------
    >>> Security Exception
    >>> Description: The application attempted to perform an operation not
    >>> allowed
    >>> by the security policy. To grant this application the required
    >>> permission
    >>> please contact your system administrator or change the application's
    >>> trust
    >>> level in the configuration file.
    >>> Exception Details: System.Security.SecurityException: Request for
    >>> the
    >>> permission of type System.Security.Permissions.FileIOPermission,
    >>> mscorlib, Version=1.0.5000.0, Culture=neutral,
    >>> PublicKeyToken=b77a5c561934e089 failed.
    >>> Source Error:
    >>>
    >>> Line 9: string strXmlFileName = @".\Sample.xml";
    >>> Line 10: DataSet dsBasic = new DataSet();
    >>> Line 11: dsBasic.ReadXml(strXmlFileName);
    >>> Line 12:
    >>> Source File: e:\default.aspx Line: 11
    >>> Stack Trace:
    >>>
    >>> [SecurityException: Request for the permission of type
    >>> System.Security.Permissions.FileIOPermission, mscorlib,
    >>> Version=1.0.5000.0,
    >>> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.]
    >>> System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
    >>> grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
    >>> PermissionToken permToken) +675
    >>> System.Security.CodeAccessSecurityEngine.Check(PermissionToken
    >>> permToken,
    >>> CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
    >>> checkFrames,
    >>> Int32 unrestrictedOverride) +0
    >>> System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
    >>> cap,
    >>> StackCrawlMark& stackMark) +88
    >>> System.Security.CodeAccessPermission.Demand() +62
    >>> System.IO.Path.GetFullPath(String path) +90
    >>> System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
    >>> +599
    >>> System.Xml.XmlTextReader..ctor(String url, XmlNameTable nt) +91
    >>> System.Xml.XmlTextReader..ctor(String url) +65
    >>> System.Data.DataSet.ReadXml(String fileName) +48
    >>> ASP.default_aspx.Page_Load(Object Sender, EventArgs e) in
    >>> e:\content\winisp\paihungchen\paihungchen.members.winisp.net\default
    >>> .a
    >>> spx:11
    >>> System.Web.UI.Control.OnLoad(EventArgs e) +67
    >>> System.Web.UI.Control.LoadRecursive() +35
    >>> System.Web.UI.Page.ProcessRequestMain() +2112
    >>> System.Web.UI.Page.ProcessRequest() +218
    >>> System.Web.UI.Page.ProcessRequest(HttpContext context) +18
    >>> System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExec
    >>> ut
    >>> ionStep.Execute()
    >>> +179
    >>> System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    >>> Boolean&
    >>> completedSynchronously) +8
     
    Dominick Baier [DevelopMentor], Nov 25, 2005
    #4
    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:
    957
    =?Utf-8?B?cGF1bA==?=
    Oct 1, 2004
  2. Eric Phetteplace

    System.Security.Permissions.FileIOPermission

    Eric Phetteplace, Jun 11, 2004, in forum: ASP .Net Security
    Replies:
    2
    Views:
    177
    Eric Phetteplace
    Jun 12, 2004
  3. Usman Ghani
    Replies:
    0
    Views:
    150
    Usman Ghani
    Apr 17, 2006
  4. Leyla
    Replies:
    2
    Views:
    690
    Leyla
    Aug 17, 2006
  5. Replies:
    0
    Views:
    316
Loading...

Share This Page