Hi Schemer,
Can you provide the full stack trace of this exception? This will reveal
much important information of the failure.
Based on the error message, this exception is most likely of type
SecurityException, which is thrown by .Net Code Access Security engine. The
Net SecurityException is most likely caused by running the application
from a partial trusted location, because CLR will give limited permission
to partial trusted location running application. So, can you provide more
context information of your problem and application? For example, where do
you launch the application, local folder or network share?
It is strange that your application throws SecurityException while
constructing DirectoryInfo for current folder ".", because I have created a
little sample project which calls DirectoryInfo di = new
DirectoryInfo("."). Then I placed this test assembly in a network share
folder and no SecurityException will generate in the test. So, I recommend
you provide more detailed information to help me reproduce the problem.
This will be more efficient to reduce the troubleshooting time. Thanks.
Finally, setting FileIOPermission.AllLocalFiles property to
FileIOPermissionAccess.Read does not mean that it will give file read I/O
permission to all local files. But, it means that you want to check your
application's file read I/O permission to all local files. To explicitly
test this, you should use FileIOPermission.Demand method to force the .Net
runtime security checking. Actually, if this property can be used to grant
FileIOPermission to an application, this will become a big security hole,
because any untrusted application can use this property to acquire
FileIOPermission, which workarounds the .Net CAS engine.
Additionally, there is an easy to understand .Net CAS article in
codeproject, it will provide more useful .Net CAS background information to
you:
"Understanding .NET Code Access Security"
http://www.codeproject.com/dotnet/UB_CAS_NET.asp
I look forward to your further information. Thanks
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.