File Access Error...More

G

Guest

I have a .Net Console Application. I installed it on a server. I created a
bat file on the server which passes the appropriate parms to the program to
run. This application accesses and updates other files on mapped drives.
When I am logged on to the server and run the application, it runs just fine.

When I log on and run from my workstation and double clicking on the bat
file to invoke the application, I get the following error:

Unable to open log file **** Processing Terminated ******
Detail Error Message: Request for the permission of type
System.Security.Permiss
ions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyT
oken=b77a5c561934e089 failed.

File Name that program was attempting to read was: F:\Products\Batch
Jobs\Metric
BatchLoad\log20054.txt


The file being reference in error is located on the server where the
application resides. I thought maybe when the application was getting the
current directory to find the file to open, that perhaps it was getting
confused (because "f" drive is the name of the mapped drive on my machine,
but "D" is the drive letter which is used on the server. Either way, I get
the same error.

I have signed onto the server where the application is AS WELL as my
WORKSTATION and used the .Net Wizard to grant the application full trust to
the application.

So what am I missing in order to enable me to sign on to my workstation and
double click the bat file to enable me to successfully run the application?

Thanks in advance for your assistance!!
 
C

Chris R. Timmons

Jim,

You've run into the .Net Code Access Security (CAS) system the way
most .Net developers do - trying to run a .Net .EXE from a network
drive.

The .Net runtime gives .EXEs different security permissions depending
upon where the .EXE is run from. An .EXE executed from a local (C:)
drive is given full permissions. That same .EXE run from a network
(F:) drive is only given partial permissions.

Check out this link for an introduction to CAS:

http://msdn.microsoft.com/library/en-us/dnnetsec/html/casbasics.asp

The .Net documentation is kind of "dense" when discussing CAS, but
once you get over the initial learning curve, things get easier.

There are more articles about CAS on MSDN, and even a video on MSDN
TV. And here's a .Net security blog:

http://blogs.msdn.com/shawnfa/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top