472,951 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

SoapFormatter only works in Full Trust?

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

Martyn Fewtrell
mf*******@networkclub.co.uk

May 5 '07 #1
5 2563
I couldn't find where the soapformatter class requires full trust, granted I
didn't look long and hard either.

If that's the case, you will need to use CAS policy to remove that
restriction. Use the configuration utility to configure the appropriate
policy on the assembly. Ideally, you would grant the assembly full trust
(not recommended) or some combination of permissions to allow it run that is
less than full trust.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Martyn Fewtrell" <mf*******@newsgroup.nospamwrote in message
news:B1**********************************@microsof t.com...
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.
--
Regards

Martyn Fewtrell
mf*******@networkclub.co.uk

May 6 '07 #2
Alvin

Thanks for your response.

If you look at the following MSDN article:

http://msdn2.microsoft.com/en-us/lib...hf(VS.80).aspx

There is a section at the bottom that seems to indicate that the serialise
method requires Full Trust.

--------------------------------------------------------------------
..NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially
trusted code. For more information, see .

---------------------------------------------------------------------

I assume where you are reffering to the CAS policy you are reffering to
editing the machine.config file and adding a line that basically says the
equivalent of grant SoapFormatter full trust but nothing else?

--
Regards

Martyn Fewtrell
"Alvin Bruney [MVP]" wrote:
I couldn't find where the soapformatter class requires full trust, granted I
didn't look long and hard either.

If that's the case, you will need to use CAS policy to remove that
restriction. Use the configuration utility to configure the appropriate
policy on the assembly. Ideally, you would grant the assembly full trust
(not recommended) or some combination of permissions to allow it run that is
less than full trust.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Martyn Fewtrell" <mf*******@newsgroup.nospamwrote in message
news:B1**********************************@microsof t.com...
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.
--
Regards

Martyn Fewtrell
mf*******@networkclub.co.uk


May 7 '07 #3
Yes i was, its rather easy to create a cas policy and push it to the prod.
environment. That will fix you up.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Martyn Fewtrell" <mf*******@newsgroup.nospamwrote in message
news:6A**********************************@microsof t.com...
Alvin

Thanks for your response.

If you look at the following MSDN article:

http://msdn2.microsoft.com/en-us/lib...hf(VS.80).aspx

There is a section at the bottom that seems to indicate that the serialise
method requires Full Trust.

--------------------------------------------------------------------
.NET Framework Security

Full trust for the immediate caller. This member cannot be used by
partially
trusted code. For more information, see .

---------------------------------------------------------------------

I assume where you are reffering to the CAS policy you are reffering to
editing the machine.config file and adding a line that basically says the
equivalent of grant SoapFormatter full trust but nothing else?

--
Regards

Martyn Fewtrell
"Alvin Bruney [MVP]" wrote:
>I couldn't find where the soapformatter class requires full trust,
granted I
didn't look long and hard either.

If that's the case, you will need to use CAS policy to remove that
restriction. Use the configuration utility to configure the appropriate
policy on the assembly. Ideally, you would grant the assembly full trust
(not recommended) or some combination of permissions to allow it run that
is
less than full trust.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Martyn Fewtrell" <mf*******@newsgroup.nospamwrote in message
news:B1**********************************@microso ft.com...
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.
--
Regards

Martyn Fewtrell
mf*******@networkclub.co.uk



May 7 '07 #4
Hi Martyn,

As you have already knew, the SoapFormatter.Serialize requires immediate
caller must have full trust. There're several approaches for such scenario,
please see following article for more information:

#How To: Use Code Access Security in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/library/ms998326.aspx
For example, one possible approach is to create a wrapper assembly,
configure this wrapper assembly to run with full trust, and apply
AllowPartialTrustedCallersAttribute to this wrapper assembly; then you can
call this wrapper assembly from your web application.
Hope this helps. Please feel free to let me know if there's anything
unclear. Thanks.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 9 '07 #5
Hi Martyn,

Please feel free to let us know if the issue is still not resolved. Thanks.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 14 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philip K | last post by:
I was trying to use Soap serialisation to save some systems settings how ever it fails if the settings contain a Font object, works fine if the Font object is not in the object being serialised. ...
2
by: Jarda | last post by:
Hi all, i'm looking for some performance comparison some charts. I have read the xmlserializer is better, more flexible and faster (analyzing data types in constructor), but there are some...
1
by: Jim S | last post by:
I have an application where I have to make a tree of objects. To do this, I have my own node class. At certain points in the application, I need to save data. I am having a problem with the...
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
0
by: JackRazz | last post by:
I'm trying to serialize a collection to a file stream by serializing each object individually. The code below works fine with the BinaryFormatter, but the SoapFormatter reads the first object and...
0
by: Lucas Tam | last post by:
Hi all, I've created an assembly with a strong name and added it to .NET's configuration manager with Full Trust. However, the assmebly still will not load in the Internet Zone. I can...
20
by: Jason Dravet | last post by:
Some time ago I wrote an application that controls the projectors in our classrooms(turn on, turn off, and volume control). This application is written in VB.net 2003. It was working perfectly...
5
by: =?Utf-8?B?S1A=?= | last post by:
I have an asp.net application that I've installed on several of my customers laptops (they run a localized IIS). I've been doing this for years without and issue. Today I attempted to install...
0
by: Alphamacaroon | last post by:
All, I am using the SoapFormatter class to parse/deserialize SOAP/RPC calls from a remote client. The SoapFormatter works like a charm when the message contains simple parameter types (like...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.