我尝试了多种方法这是我最新的方法,我试图不触发错误但无济于事我仍然收到 FileIOPermission 错误
完整错误是
请求“System.Security.Permissions.FileIOPermission、mscorlib、Version=4.0.0.0、Culture=neutral、PublicKeyToken=b77a5c561934e089”类型的权限失败
我正在使用的代码如下
Dim permissions As New Security.PermissionSet(Security.Permissions.PermissionState.None)
permissions.AddPermission(New Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted))
permissions.AddPermission(New Security.Permissions.SecurityPermission(Security.Permissions.SecurityPermissionFlag.Execution))
permissions.AddPermission(New Security.Permissions.SecurityPermission(Security.Permissions.SecurityPermissionFlag.Assertion))
permissions.Assert()
ReportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(permissions)
Dim asm As Reflection.Assembly = Reflection.Assembly.Load("ReportingServiceUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cca1b177d76f2036")
Dim asm_name As Reflection.AssemblyName = asm.GetName()
ReportViewer1.LocalReport.AddFullTrustModuleInSandboxAppDomain(New Security.Policy.StrongName(New Security.Permissions.StrongNamePublicKeyBlob(asm_name.GetPublicKeyToken()), asm_name.Name, asm_name.Version))
dll中使用的代码如下
Public Sub Add(ByVal group As String, ByVal groupCurrentPageNumber As String)
Try
If _GroupWithRunningMaxPageNumber.ContainsKey(group) Then
_GroupWithRunningMaxPageNumber(group) = groupCurrentPageNumber
Else
If _GroupWithRunningMaxPageNumber.Count = 0 Then
Dim fileName = "C:\Working Folder\ms-dot-net-report-viewer-group-pagenation\ReportingServiceUtils\test.xml"
sw = New System.IO.StreamWriter(fileName, False)
sw.WriteLine("<root>")
sw.WriteLine("</root>")
sw.Close()
sw.Dispose()
End If
_GroupWithRunningMaxPageNumber.Add(group, groupCurrentPageNumber)
sw.WriteLine("<Group current='" & group & "' lastPage='" & CStr(groupCurrentPageNumber) & "'/>", 1, 1)
sw.Close()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
有没有人看到下面的代码有什么问题