Hi
I'm trying to deploy a VB.net application on a shared server. In one of the part of the program I try to create a report with Excel.
Here is the code.
Dim myExcel As New Microsoft.Office.Interop.Excel.Application
Dim myBook As Microsoft.Office.Interop.Excel.Workbook = myExcel.Workbooks.Open(prFileName)
Dim mySheet As Microsoft.Office.Interop.Excel.Worksheet = myBook.Sheets.Item("Sheet1")
myExcel.DisplayAlerts = False
Dim eRow As Integer = 17, eCol As Integer = 1
For Each prRow In gvStudents.Rows
Dim prSelected As System.Web.UI.WebControls.CheckBox = prRow.FindControl("cbSelected")
Dim Student_Id As Integer = CLng(gvStudents.DataKeys(prRow.RowIndex).Values(0))
If prSelected.Checked = True Then
Dim str_Name_Surname As String = Trim(prRow.Cells(4).Text) & " " & Trim(prRow.Cells(5).Text)
mySheet.Range("A" & 12).Value = str_Name_Surname
Dim dt_Exam_Date As Date = prRow.Cells(10).Text
mySheet.Range("A" & eRow).Value = Format(dt_Exam_Date, "dd/MM/yyyy")
mySheet.Range("B" & eRow).Value = Trim(prRow.Cells(8).Text)
Dim dt_Expiry_Date As Date = prRow.Cells(11).Text
mySheet.Range("C" & eRow).Value = Format(dt_Expiry_Date, "dd/MM/yyyy")
eRow += 1
End If
Next
myBook.Save()
myBook.Close()
mySheet = Nothing
myBook = Nothing
myExcel.Quit()
myExcel = Nothing
I get a "Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers."
I've added Full Trust but it get over ridden by the Web Hosting company.
I've added impersonation - but the Web Hosting company doesn't allow that.
They only allow medium trust.
They've told me that they are willing to change medium trust config file - If I can tell them what machine permisssions Excel needs.
Can anyone give me a hand with this please.
Regards
I'm trying to deploy a VB.net application on a shared server. In one of the part of the program I try to create a report with Excel.
Here is the code.
Dim myExcel As New Microsoft.Office.Interop.Excel.Application
Dim myBook As Microsoft.Office.Interop.Excel.Workbook = myExcel.Workbooks.Open(prFileName)
Dim mySheet As Microsoft.Office.Interop.Excel.Worksheet = myBook.Sheets.Item("Sheet1")
myExcel.DisplayAlerts = False
Dim eRow As Integer = 17, eCol As Integer = 1
For Each prRow In gvStudents.Rows
Dim prSelected As System.Web.UI.WebControls.CheckBox = prRow.FindControl("cbSelected")
Dim Student_Id As Integer = CLng(gvStudents.DataKeys(prRow.RowIndex).Values(0))
If prSelected.Checked = True Then
Dim str_Name_Surname As String = Trim(prRow.Cells(4).Text) & " " & Trim(prRow.Cells(5).Text)
mySheet.Range("A" & 12).Value = str_Name_Surname
Dim dt_Exam_Date As Date = prRow.Cells(10).Text
mySheet.Range("A" & eRow).Value = Format(dt_Exam_Date, "dd/MM/yyyy")
mySheet.Range("B" & eRow).Value = Trim(prRow.Cells(8).Text)
Dim dt_Expiry_Date As Date = prRow.Cells(11).Text
mySheet.Range("C" & eRow).Value = Format(dt_Expiry_Date, "dd/MM/yyyy")
eRow += 1
End If
Next
myBook.Save()
myBook.Close()
mySheet = Nothing
myBook = Nothing
myExcel.Quit()
myExcel = Nothing
I get a "Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers."
I've added Full Trust but it get over ridden by the Web Hosting company.
I've added impersonation - but the Web Hosting company doesn't allow that.
They only allow medium trust.
They've told me that they are willing to change medium trust config file - If I can tell them what machine permisssions Excel needs.
Can anyone give me a hand with this please.
Regards