Re: Strange problem with FileIOPermission

From: Shell (shelld00d_at_yahoo.com)
Date: 09/01/04


Date: 31 Aug 2004 21:08:52 -0700

Nicole,

The exception is thrown when I click the button that tries to construct
the class. The weird thing is that it never even gets to the
constructor. From my console output, I can see that the assembly gets
loaded:

'Consumer.exe': Loaded 'e:\fun\security\consumer\bin\debug\class1.dll',
Symbols loaded.

In my button code, all I have is:

MyClass foo = new MyClass();

I put a breakpoint here, which it never hits. The security exception is
thrown *before* it gets here. Here's the full text of the exception:

An unhandled exception of type 'System.Security.SecurityException'
occurred in system.windows.forms.dll

Additional information: Security error.

Unhandled Exception: System.Security.SecurityException: Security error.
at Consumer.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Consumer.Form1.Main() in e:\fun\security\consumer\form1.cs:line
84

The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true">
<IPermission
class="System.Security.Permissions.StrongNameIdentityPermission,
mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<<
comment: removed >>"
version="1"
PublicKeyBlob="<< comment: removed >>"
Name="Consumer"
AssemblyVersion="1.0.1705.17363"/>
<IPermission
class="System.Security.Permissions.UrlIdentityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<< comment: removed
>>"
version="1"

Url="file://E:/Fun/Security/Consumer/bin/Debug/Consumer.exe"/>
<IPermission
class="System.Security.Permissions.ZoneIdentityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<< comment: removed
>>"
version="1"
Zone="MyComputer"/>
</PermissionSet>

The refused set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.FileIOPermission,
mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<<
comment: removed >>"
version="1"
Read="c:\myOtherFolder"
Write="c:\myOtherFolder"
Append="c:\myOtherFolder"
PathDiscovery="c:\myOtherFolder"/>
</PermissionSet>

If I remove the [assembly: ] directive from my forms application,
everything works fine... I don't see why it doesn't work if my forms
app explicitly rejects permission to the folder.

Any ideas?



Relevant Pages

  • Re: Unhelpful exception message when trying to save data in Access db
    ... Source: "mscorlib" ... Inspect the InnerException property of the exception being thrown using the debugger. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Differences between these cast operations / statements?
    ... Regarding o, if it fails an exception will be thrown, whereas o as ... int32 will return null if it 'fails' but will not thrown an exception. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Exchange 2007 OWA Errors
    ... Exception message: ... contacted via RPC interface, error 0x5.". ... Int32[]& mapping) ... QueryFilter filter, SortBy sortBy, Int32 maxResults, IEnumerable`1 ...
    (microsoft.public.exchange.admin)
  • Exchange 2007 OWA Errors
    ... Windows 2003/Exchange 2003 server, which is retiring. ... Exception message: ... Int32[]& mapping) ... QueryFilter filter, SortBy sortBy, Int32 maxResults, IEnumerable`1 ...
    (microsoft.public.exchange.admin)
  • RE: Detailed ASP.Net info not displaying in browser
    ... HTTP 500 page when an exception is thrown from the web service. ... at VOSE.Data.DataRequest.dr_DB2Process.DeleteCommRows(String company, String ... objQueue, tOrderManagementIndicator omindicator, Int32 intTriggerId) in ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.xml)