Home All Groups Group Topic Archive Search About

MemoryStream requires FileIOPermission ???

Author
7 Jun 2005 9:12 AM
D.Z. Simpson
I'm working on a .NET Winforms control used in a web page. It has a
LoadFromString method used to load information from a hidden html field. The
string is created on the server side via corresponding SaveToString method.

LoadFromString decodes the string into binary format in a byte array,
creates a MemoryStream and a BinaryReader on the stream. Now that worked
great in .NET 1.0 but when we moved to .NET 1.1 recently, it started to
throw exceptions about FileIOPermissions not assigned to the component. That
happens from the Internet and Intranet zones, while it works fine from my
PC. With .NET 1.0 it worked with the default security settings in all zones.

Does anybody have an idea how to avoid that permission being requied ?

Thank you very much!

Author
7 Jun 2005 11:12 AM
Nicole Calinoiu
I can't seem to find any FileIOPermission requirement in either MemoryStream
or BinaryReader.  Might you be able to post the full exception details
returns by its ToString method (incl. the call stack listing)?



Show quoteHide quote
"D.Z. Simpson" <d_z_simp***@yahoo.com> wrote in message
news:eJAw4hzaFHA.2884@tk2msftngp13.phx.gbl...
> I'm working on a .NET Winforms control used in a web page. It has a
> LoadFromString method used to load information from a hidden html field.
> The string is created on the server side via corresponding SaveToString
> method.
>
> LoadFromString decodes the string into binary format in a byte array,
> creates a MemoryStream and a BinaryReader on the stream. Now that worked
> great in .NET 1.0 but when we moved to .NET 1.1 recently, it started to
> throw exceptions about FileIOPermissions not assigned to the component.
> That happens from the Internet and Intranet zones, while it works fine
> from my PC. With .NET 1.0 it worked with the default security settings in
> all zones.
>
> Does anybody have an idea how to avoid that permission being requied ?
>
> Thank you very much!
>
Author
7 Jun 2005 7:21 PM
D.Z. Simpson
Thank you, I found that the exception happens in our custom
SerializationBinder. We call Assembly.GetName() there to check whether the
stream was saved using the same version of the control. It seems that
Assembly.GetName() method requires FileIOPermission.

Show quoteHide quote
"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:ucvABH1aFHA.3840@tk2msftngp13.phx.gbl...
>I can't seem to find any FileIOPermission requirement in either
>MemoryStream or BinaryReader.  Might you be able to post the full exception
>details returns by its ToString method (incl. the call stack listing)?
>
>
>
> "D.Z. Simpson" <d_z_simp***@yahoo.com> wrote in message
> news:eJAw4hzaFHA.2884@tk2msftngp13.phx.gbl...
>> I'm working on a .NET Winforms control used in a web page. It has a
>> LoadFromString method used to load information from a hidden html field.
>> The string is created on the server side via corresponding SaveToString
>> method.
>>
>> LoadFromString decodes the string into binary format in a byte array,
>> creates a MemoryStream and a BinaryReader on the stream. Now that worked
>> great in .NET 1.0 but when we moved to .NET 1.1 recently, it started to
>> throw exceptions about FileIOPermissions not assigned to the component.
>> That happens from the Internet and Intranet zones, while it works fine
>> from my PC. With .NET 1.0 it worked with the default security settings in
>> all zones.
>>
>> Does anybody have an idea how to avoid that permission being requied ?
>>
>> Thank you very much!
>>
>
>
Author
7 Jun 2005 7:06 PM
Nicole Calinoiu
That's because of the code base information stored in the AssemblyName.  It
does seem bit silly that the GetVersion method on Assembly is internal
rather than public, but there are other ways to retrieve the version, such
as parsing it out of the string returned from the assembly's FullName
property.



Show quoteHide quote
"D.Z. Simpson" <d_z_simp***@yahoo.com> wrote in message
news:uCj5S24aFHA.2444@TK2MSFTNGP15.phx.gbl...
> Thank you, I found that the exception happens in our custom
> SerializationBinder. We call Assembly.GetName() there to check whether the
> stream was saved using the same version of the control. It seems that
> Assembly.GetName() method requires FileIOPermission.
>
> "Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
> news:ucvABH1aFHA.3840@tk2msftngp13.phx.gbl...
>>I can't seem to find any FileIOPermission requirement in either
>>MemoryStream or BinaryReader.  Might you be able to post the full
>>exception details returns by its ToString method (incl. the call stack
>>listing)?
>>
>>
>>
>> "D.Z. Simpson" <d_z_simp***@yahoo.com> wrote in message
>> news:eJAw4hzaFHA.2884@tk2msftngp13.phx.gbl...
>>> I'm working on a .NET Winforms control used in a web page. It has a
>>> LoadFromString method used to load information from a hidden html field.
>>> The string is created on the server side via corresponding SaveToString
>>> method.
>>>
>>> LoadFromString decodes the string into binary format in a byte array,
>>> creates a MemoryStream and a BinaryReader on the stream. Now that worked
>>> great in .NET 1.0 but when we moved to .NET 1.1 recently, it started to
>>> throw exceptions about FileIOPermissions not assigned to the component.
>>> That happens from the Internet and Intranet zones, while it works fine
>>> from my PC. With .NET 1.0 it worked with the default security settings
>>> in all zones.
>>>
>>> Does anybody have an idea how to avoid that permission being requied ?
>>>
>>> Thank you very much!
>>>
>>
>>
>
>
Author
8 Jun 2005 12:37 PM
D.Z. Simpson
Ok we now parse Assembly.FullName to get the version,
thanks again!

Show quoteHide quote
"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:%23uTy9Q5aFHA.3144@TK2MSFTNGP14.phx.gbl...
> That's because of the code base information stored in the AssemblyName.
> It does seem bit silly that the GetVersion method on Assembly is internal
> rather than public, but there are other ways to retrieve the version, such
> as parsing it out of the string returned from the assembly's FullName
> property.
>
>
>
> "D.Z. Simpson" <d_z_simp***@yahoo.com> wrote in message
> news:uCj5S24aFHA.2444@TK2MSFTNGP15.phx.gbl...
>> Thank you, I found that the exception happens in our custom
>> SerializationBinder. We call Assembly.GetName() there to check whether
>> the stream was saved using the same version of the control. It seems that
>> Assembly.GetName() method requires FileIOPermission.
>>
>> "Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
>> news:ucvABH1aFHA.3840@tk2msftngp13.phx.gbl...
>>>I can't seem to find any FileIOPermission requirement in either
>>>MemoryStream or BinaryReader.  Might you be able to post the full
>>>exception details returns by its ToString method (incl. the call stack
>>>listing)?
>>>
>>>
>>>
>>> "D.Z. Simpson" <d_z_simp***@yahoo.com> wrote in message
>>> news:eJAw4hzaFHA.2884@tk2msftngp13.phx.gbl...
>>>> I'm working on a .NET Winforms control used in a web page. It has a
>>>> LoadFromString method used to load information from a hidden html
>>>> field. The string is created on the server side via corresponding
>>>> SaveToString method.
>>>>
>>>> LoadFromString decodes the string into binary format in a byte array,
>>>> creates a MemoryStream and a BinaryReader on the stream. Now that
>>>> worked great in .NET 1.0 but when we moved to .NET 1.1 recently, it
>>>> started to throw exceptions about FileIOPermissions not assigned to the
>>>> component. That happens from the Internet and Intranet zones, while it
>>>> works fine from my PC. With .NET 1.0 it worked with the default
>>>> security settings in all zones.
>>>>
>>>> Does anybody have an idea how to avoid that permission being requied ?
>>>>
>>>> Thank you very much!
>>>>
>>>
>>>
>>
>>
>
>