473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 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 2583
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.