开发者

System.Security.SecurityException: on calendar

Hello I am receiving this error message when my application is being viewed on the remote machine(internet)

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.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 

Stack Trace:

Here is the full codes for the application:

    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

Can someone help me fixt or tell me what to do.


The user that the application is running under doesn't have access to the temporary folder or the specific file(schedule.Bin).

This may be of some help:

How Do I Determine the Security Account that IIS Uses to Run My Web Site?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜