0

Got this:

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. ( at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)....

There are plenty of references on the web related to this problem, but they all refer to ASP.NET applications or they are related to an assembly that made it somehow "illegal" into the GAC - that's not my problem.

I have a local drive D:\ that contains this:

D:\APLData\T

D:\APLData\I

D:\APLData\M

D:\APLData\P

D:\APLData\Z

At the some time I have network drives T, I, M, P and Z pointing to exactly these folders. In other words, these two paths both point to the same file:

D:\AplData\T\FlipDB_Dev\Test\ShareTest.DWS

T:\FlipDB_Dev\Test\ShareTest.DWS

Now when I start the program in question from the network drive (T) then I get the error. When I start the program from the local drive (D) than it works.

Any ideas how to solve this problem?

Kai

Levon
  • 138,105
  • 33
  • 200
  • 191
KaiJaeger
  • 39
  • 1
  • 7
  • I found this: [link](http://stackoverflow.com/questions/148879/why-does-my-net-application-crash-when-run-from-a-network-drive/10966992#10966992) which originally escaped my attention because it did not contain the error message, which I added to that thread as well. – KaiJaeger Jun 10 '12 at 07:17
  • Where is your code executing from? This a windows app? Web app? – Kenneth Ito Jun 12 '12 at 22:24

2 Answers2

0

Have you checked the permissions for the files/folders. Especially when linking to a file on a LAN-share ASP.NET won't automatically have permissions to access those files since the permissions is set on the machine that physically hosts the file.

One thing you could try is to set full permissions to the user group "Everyone", however, don't forget to remove that permission once you've found a correct permissions level.

Update: Check this link, might come in handy

http://www.codeproject.com/Articles/19830/How-to-Access-Network-Files-using-asp-net

JaggenSWE
  • 1,950
  • 2
  • 24
  • 41
  • No, this has nothing to do with my problem: this is about .NET security, not file permissions. – KaiJaeger Jun 10 '12 at 07:14
  • ASP.NET SecurityExceptions will occur when you have permissions issues, and since you're trying to access a file when it throws the exception it's most likely a permissions issue. However, if you use the file as a component it might be the you need a higher trust level to run it. But most likely it IS a permissions issue, you COULD try this by copying the file from the mapped network drive to the same directory as the web app and try referencing it from there. – JaggenSWE Jun 10 '12 at 16:35
0

Mapped drives are specific to a user. If you have permission and you are running the app as you, then it should work, if this is different accounts then you both need permissions and the same drives mapped to teh same places. Save yourself a good bit of heartache and use UNCs.

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39