473,588 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = "Serializat ion Failed"
myNotification. Message = "Serializat ion Failed" & ex.ToString
myNotification. SendNotificatio n(myNotificatio n)
End Try

End Sub

and

Private Function DeserializeClas s(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.Deseri alize(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*******@netwo rkclub.co.uk

May 5 '07 #1
5 2604
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*******@news group.nospamwro te in message
news:B1******** *************** ***********@mic rosoft.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 = "Serializat ion Failed"
myNotification. Message = "Serializat ion Failed" & ex.ToString
myNotification. SendNotificatio n(myNotificatio n)
End Try

End Sub

and

Private Function DeserializeClas s(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.Deseri alize(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*******@netwo rkclub.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*******@news group.nospamwro te in message
news:B1******** *************** ***********@mic rosoft.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 = "Serializat ion Failed"
myNotification. Message = "Serializat ion Failed" & ex.ToString
myNotification. SendNotificatio n(myNotificatio n)
End Try

End Sub

and

Private Function DeserializeClas s(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.Deseri alize(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*******@netwo rkclub.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*******@news group.nospamwro te in message
news:6A******** *************** ***********@mic rosoft.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*******@news group.nospamwro te in message
news:B1******* *************** ************@mi crosoft.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 = "Serializat ion Failed"
myNotification. Message = "Serializat ion Failed" &
ex.ToString
myNotification. SendNotificatio n(myNotificatio n)
End Try

End Sub

and

Private Function DeserializeClas s(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.Deseri alize(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*******@netwo rkclub.co.uk



May 7 '07 #4
Hi Martyn,

As you have already knew, the SoapFormatter.S erialize 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
AllowPartialTru stedCallersAttr ibute 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
2281
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. Font is marked in the MS documentation. Exception has been thrown by the target of an invocation. at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
2
6282
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 limitation (i.e. public members). SoapFormatter is better to serialize arbitrary data. I have done some tests and SoapFormatter is faster 5 times than XmlSerializer. I don't undestand it, I have tried large arrays, small string .... the result seems the...
1
2676
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 SoapFormatter. The following program gets the exception: "The data at the root level is invalid. Line 55, position -460." This code works fine if I use a BinaryFormatter instead of a SoapFormatter. Any ideas? Here is a test program:
2
3754
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 implemented using Inherits System.Collections.Specialized.NameObjectCollectionBase and also has the <Serializable()> flag before the class name declaration. In the calling code, I'm successfully serializing the object to an XML file using a...
0
1617
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 just goes to the end of the file. After reading the first object, the fStream.Position is pointed to the end of the file. The collection serializes/deserilizes fine when I just serialize the hashtable vs. each object in the hashtable. Does...
0
1043
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 only get the Assembly to load if I give Full Trust to a URL as well.
20
2863
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 until XP SP2 was installed on the PCs. Now when the power on or power off button is pressed the following message is displayed: An unhandled exception has occurred in your application. If you click Continue, the application will ignore this...
5
4810
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 this application on a laptop that belonged to a contractor (i.e. not supplied by us). I brought it onto the domain, installed what I needed to, and everything seemed fine. However, when I run the app (i.e. access the default.aspx page via IE), I...
0
1100
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 strings, ints, bools, etc), but it throws an error when the message contains any sort of an array. For example, the incoming SOAP message might look like:
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7862
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8357
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6634
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2372
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1196
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.