Home All Groups Group Topic Archive Search About
Author
13 Apr 2005 9:57 PM
Greg
i will state i am new to this, so any help is great.  I am work with out
imaging people to make a hardware independent image.  when we bring down a
image we log on as the local admin.  the first few forms are run locally on
the machine which connects to a server share.  then the second half is
executed from the sever.  that way if we change the forms any we just place
them on the server, not rebuilding the image everytime something needs to be
changed.  When i execute the remote code i get the follow:


System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
   at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
   at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
   at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
cap, StackCrawlMark& stackMark)
   at System.Security.CodeAccessPermission.Demand()
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
detectEncodingFromByteOrderMarks, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path)
   at HWIDMENU.Form1.Form1_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


I was looking at the Security.Permissions.FileIOPermission, but i don't know
what to do to allow it to read files and install software from the server.

Author
14 Apr 2005 8:30 AM
Adam Goossens
Greg,

The security component of .NET is called "Code Access Security" (or CAS
for short) and defines what actions code is allowed to perform based on
where it comes from. Code that is located on your local machine is
usually run with "Full Trust", meaning there isn't anything it can't do.

When you run code from a network location it runs with a much more
restrictive set of permissions. This means that the code that is being
stored on your server may not have the permissions it needs to access
files stored on your local machine (this is by design).

Now, you are able to change the security policy for Intranet code by
doing the following:

Control Panel --> Administrative Tools --> .NET Configuration 1.1.

From there, expand "Runtime Security Policy", then "Machine". From
there, Open "Code Groups", "All Code" and then right click on
"LocalIntranet_Zone" and choose "Properties".

Jump to the "Permission Set" tab and you'll see that all code that comes
from the Intranet is granted the "LocalIntranet" permission set. You can
see all of the permissions it's granted...isolated file storage, user
interface, that sorta thing.

Now, the quick-and-dirty fix is to select "FullTrust" from that
drop-down combo box. Save your dialog screens and close down the
configuration tool. That should solve the problem.

There are better ways of doing this (like not granting Full Trust and
creating your own permission sets on a per-assembly basis), but I'll
leave them up to you ;)

Hope this helps.
Regards,
-Adam.

Greg wrote:
Show quoteHide quote
> i will state i am new to this, so any help is great.  I am work with out
> imaging people to make a hardware independent image.  when we bring down a
> image we log on as the local admin.  the first few forms are run locally on
> the machine which connects to a server share.  then the second half is
> executed from the sever.  that way if we change the forms any we just place
> them on the server, not rebuilding the image everytime something needs to be
> changed.  When i execute the remote code i get the follow:
>
>
> System.Security.SecurityException: Request for the permission of type
> System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
>    at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
> grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> PermissionToken permToken)
>    at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
> permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
> checkFrames, Int32 unrestrictedOverride)
>    at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
> cap, StackCrawlMark& stackMark)
>    at System.Security.CodeAccessPermission.Demand()
>    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
> Boolean bFromProxy)
>    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access, FileShare share, Int32 bufferSize)
>    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
> detectEncodingFromByteOrderMarks, Int32 bufferSize)
>    at System.IO.StreamReader..ctor(String path)
>    at HWIDMENU.Form1.Form1_Load(Object sender, EventArgs e)
>    at System.Windows.Forms.Form.OnLoad(EventArgs e)
>    at System.Windows.Forms.Form.OnCreateControl()
>    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
>    at System.Windows.Forms.Control.CreateControl()
>    at System.Windows.Forms.Control.WmShowWindow(Message& m)
>    at System.Windows.Forms.Control.WndProc(Message& m)
>    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
>    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
>    at System.Windows.Forms.Form.WmShowWindow(Message& m)
>    at System.Windows.Forms.Form.WndProc(Message& m)
>    at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
>    at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
>    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> IntPtr wparam, IntPtr lparam)
>
>
> I was looking at the Security.Permissions.FileIOPermission, but i don't know
> what to do to allow it to read files and install software from the server.
Author
14 Apr 2005 12:45 PM
Greg
Thank you very much, test it this morning worked fine. 

Show quoteHide quote
"Adam Goossens" wrote:

> Greg,
>
> The security component of .NET is called "Code Access Security" (or CAS
> for short) and defines what actions code is allowed to perform based on
> where it comes from. Code that is located on your local machine is
> usually run with "Full Trust", meaning there isn't anything it can't do.
>
> When you run code from a network location it runs with a much more
> restrictive set of permissions. This means that the code that is being
> stored on your server may not have the permissions it needs to access
> files stored on your local machine (this is by design).
>
> Now, you are able to change the security policy for Intranet code by
> doing the following:
>
> Control Panel --> Administrative Tools --> .NET Configuration 1.1.
>
>  From there, expand "Runtime Security Policy", then "Machine". From
> there, Open "Code Groups", "All Code" and then right click on
> "LocalIntranet_Zone" and choose "Properties".
>
> Jump to the "Permission Set" tab and you'll see that all code that comes
> from the Intranet is granted the "LocalIntranet" permission set. You can
> see all of the permissions it's granted...isolated file storage, user
> interface, that sorta thing.
>
> Now, the quick-and-dirty fix is to select "FullTrust" from that
> drop-down combo box. Save your dialog screens and close down the
> configuration tool. That should solve the problem.
>
> There are better ways of doing this (like not granting Full Trust and
> creating your own permission sets on a per-assembly basis), but I'll
> leave them up to you ;)
>
> Hope this helps.
> Regards,
> -Adam.
>
> Greg wrote:
> > i will state i am new to this, so any help is great.  I am work with out
> > imaging people to make a hardware independent image.  when we bring down a
> > image we log on as the local admin.  the first few forms are run locally on
> > the machine which connects to a server share.  then the second half is
> > executed from the sever.  that way if we change the forms any we just place
> > them on the server, not rebuilding the image everytime something needs to be
> > changed.  When i execute the remote code i get the follow:
> >
> >
> > System.Security.SecurityException: Request for the permission of type
> > System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
> >    at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
> > grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
> > PermissionToken permToken)
> >    at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
> > permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
> > checkFrames, Int32 unrestrictedOverride)
> >    at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
> > cap, StackCrawlMark& stackMark)
> >    at System.Security.CodeAccessPermission.Demand()
> >    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> > access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
> > Boolean bFromProxy)
> >    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> > access, FileShare share, Int32 bufferSize)
> >    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
> > detectEncodingFromByteOrderMarks, Int32 bufferSize)
> >    at System.IO.StreamReader..ctor(String path)
> >    at HWIDMENU.Form1.Form1_Load(Object sender, EventArgs e)
> >    at System.Windows.Forms.Form.OnLoad(EventArgs e)
> >    at System.Windows.Forms.Form.OnCreateControl()
> >    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
> >    at System.Windows.Forms.Control.CreateControl()
> >    at System.Windows.Forms.Control.WmShowWindow(Message& m)
> >    at System.Windows.Forms.Control.WndProc(Message& m)
> >    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
> >    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
> >    at System.Windows.Forms.Form.WmShowWindow(Message& m)
> >    at System.Windows.Forms.Form.WndProc(Message& m)
> >    at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> >    at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> >    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> > IntPtr wparam, IntPtr lparam)
> >
> >
> > I was looking at the Security.Permissions.FileIOPermission, but i don't know
> > what to do to allow it to read files and install software from the server. 
>