G
Guest
Hi there.
I posted an earlier issue under the name "That assembly does not allow
partially trusted callers" but have now identified what the issue is.
As explained before I am working in ASP.Net 2.0 using VB.Net and had
developed an application that ran correctly on my development server but
would not run on the shared hosting paltform which I use. The shared hosting
runs in medium trust and produced the error "That assembly does not allow
partially trusted callers"
Having played around a fair bit I have now (I think) narrowed this down to
the SoapFormatter class which I use to serialize and desiralize a class.
Code as follows:
Private Sub SerializeClass(ByVal _exRate As exRate, ByVal Path As String)
Try
Dim sf As New SoapFormatter
Dim fs As New FileStream(Path, FileMode.Create)
sf.Serialize(fs, _exRate)
fs.Close()
Catch ex As Exception
Dim myNotification As New Notification
myNotification.Subject = "Serialization Failed"
myNotification.Message = "Serialization Failed" & ex.ToString
myNotification.SendNotification(myNotification)
End Try
End Sub
and
Private Function DeserializeClass(ByVal Path As String) As exRate
Dim myExRate As New exRate
Try
Dim fs As New FileStream(Path, FileMode.Open)
Dim sf As New SoapFormatter
myExRate = CType(sf.Deserialize(fs), exRate)
fs.Close()
Catch ex As Exception
End Try
Return myExRate
End Function
I now understand that the SoapFormatter class only works in full trust. Is
there a work around for this issue or perhaps a better way to do the above.
I was basically trying to save the values for the properties of the class to
be used at a later date.
I posted an earlier issue under the name "That assembly does not allow
partially trusted callers" but have now identified what the issue is.
As explained before I am working in ASP.Net 2.0 using VB.Net and had
developed an application that ran correctly on my development server but
would not run on the shared hosting paltform which I use. The shared hosting
runs in medium trust and produced the error "That assembly does not allow
partially trusted callers"
Having played around a fair bit I have now (I think) narrowed this down to
the SoapFormatter class which I use to serialize and desiralize a class.
Code as follows:
Private Sub SerializeClass(ByVal _exRate As exRate, ByVal Path As String)
Try
Dim sf As New SoapFormatter
Dim fs As New FileStream(Path, FileMode.Create)
sf.Serialize(fs, _exRate)
fs.Close()
Catch ex As Exception
Dim myNotification As New Notification
myNotification.Subject = "Serialization Failed"
myNotification.Message = "Serialization Failed" & ex.ToString
myNotification.SendNotification(myNotification)
End Try
End Sub
and
Private Function DeserializeClass(ByVal Path As String) As exRate
Dim myExRate As New exRate
Try
Dim fs As New FileStream(Path, FileMode.Open)
Dim sf As New SoapFormatter
myExRate = CType(sf.Deserialize(fs), exRate)
fs.Close()
Catch ex As Exception
End Try
Return myExRate
End Function
I now understand that the SoapFormatter class only works in full trust. Is
there a work around for this issue or perhaps a better way to do the above.
I was basically trying to save the values for the properties of the class to
be used at a later date.