簡體   English   中英

System.Security.SecurityException:在日歷上

[英]System.Security.SecurityException: on calendar

您好,當我在遠程計算機(Internet)上查看我的應用程序時,我收到此錯誤消息

安全異常描述:應用程序嘗試執行安全策略不允許的操作。 要授予此應用程序所需的權限,請聯系系統管理員或在配置文件中更改應用程序的信任級別。

異常詳細信息: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error: 

Line 7:      Dim oBF As New BinaryFormatter()
Line 8:      Dim oFS As FileStream
Line 9:      Dim strPath As String = Path.GetTempPath & "schedule.Bin"
Line 10: 
Line 11:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Source File: D:\Hosting\4423045\html\please-god\appointmentscheduler.aspx.vb    Line: 9 

堆棧跟蹤:

這是該應用程序的完整代碼:

    Imports System.IO
    Imports System.Runtime.Serialization.Formatters.Binary

    Partial Class appointmentscheduler
        Inherits System.Web.UI.Page
        Dim arrCalendar(12, 31) As String
        Dim oBF As New BinaryFormatter()
        Dim oFS As FileStream
        Dim strPath As String = Path.GetTempPath & "schedule.Bin"

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If (Cache("arrCalendar") Is Nothing) Then
                If (File.Exists(strPath)) Then
                    oFS = New FileStream(strPath, FileMode.Open)
                    arrCalendar = DirectCast(oBF.Deserialize(oFS), Array)
                    oFS.Close()
                    Cache("arrCalendar") = arrCalendar
                End If
            Else
                arrCalendar = Cache("arrCalendar")
            End If
        End Sub

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        arrCalendar(Me.myCalendar.SelectedDate.Month, Me.myCalendar.SelectedDate.Day) = Me.myNotes.Text
        oFS = New FileStream(strPath, FileMode.Create)
        oBF.Serialize(oFS, arrCalendar)
        oFS.Close()
        Cache("arrCalendar") = arrCalendar
    End Sub

    Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        arrCalendar(Me.myCalendar.SelectedDate.Month, Me.myCalendar.SelectedDate.Day) = ""
        oFS = New FileStream(strPath, FileMode.Create)
        oBF.Serialize(oFS, arrCalendar)
        oFS.Close()
        Cache("arrCalendar") = arrCalendar
        Me.myNotes.Text = ""
    End Sub

    Protected Sub myCalendar_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles myCalendar.DayRender
        If arrCalendar(e.Day.Date.Month, e.Day.Date.Day) <> "" Then
            e.Cell.BackColor = Drawing.Color.Red
        End If
    End Sub

    Protected Sub myCalendar_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles myCalendar.SelectionChanged
        Me.myNotes.Text = ""
        If arrCalendar(Me.myCalendar.SelectedDate.Month, Me.myCalendar.SelectedDate.Day) <> "" Then
            Me.myNotes.Text = arrCalendar(Me.myCalendar.SelectedDate.Month, Me.myCalendar.SelectedDate.Day)
        End If
    End Sub
End Class

有人可以幫我解決問題或告訴我該怎么做。

運行該應用程序的用戶無權訪問臨時文件夾或特定文件(schedule.Bin)。

這可能會有所幫助:

如何確定IIS用於運行我的網站的安全帳戶?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM