Security Issue

G

Guest

I have created a console application which reads a database and creates an
Excel file. I can run this application just fine from my own machine. It
runs just fine when I move it to the server and if I run the application
while logged on to the server.
However, when I set the job to run as a scheduled job, I get an access
violation error when I attempt to create the excel object within my code.
So I am guessing that there must be something I am missing about how to set
the job to run on my server. Any ideas?
 
N

Nicholas Paldino [.NET/C# MVP]

Jim,

When .NET runs an assembly that is loaded from the network, it is loaded
with a limited set of permissions, because it is not sure if it should be
trusted or not.

What you need to do is go to the "Microsoft .NET <x.x> Administration"
management console from the "Administrative Tools" menu on your machine.
The <x.x> is the version number of .NET that you need to configure this for.

Once you are there, you want to configure the runtime so that your
program (identified by location, hash, or strong name) has the appropriate
permission set. In this case, you probably need some specific database
permissions.

Hope this helps.
 
G

Guest

Well, I went to the .Net Configuration 1.1 and click on "Runtime Security
Policy" and then selected "Increase Assembly Trust" and from there I selected
my application (.exe) and then indicated that it should be fully trusted.

I then ran my application with the same results.


Nicholas Paldino said:
Jim,

When .NET runs an assembly that is loaded from the network, it is loaded
with a limited set of permissions, because it is not sure if it should be
trusted or not.

What you need to do is go to the "Microsoft .NET <x.x> Administration"
management console from the "Administrative Tools" menu on your machine.
The <x.x> is the version number of .NET that you need to configure this for.

Once you are there, you want to configure the runtime so that your
program (identified by location, hash, or strong name) has the appropriate
permission set. In this case, you probably need some specific database
permissions.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jim Heavey said:
I have created a console application which reads a database and creates an
Excel file. I can run this application just fine from my own machine. It
runs just fine when I move it to the server and if I run the application
while logged on to the server.
However, when I set the job to run as a scheduled job, I get an access
violation error when I attempt to create the excel object within my code.
So I am guessing that there must be something I am missing about how to
set
the job to run on my server. Any ideas?
 
W

Willy Denoyette [MVP]

|I have created a console application which reads a database and creates an
| Excel file. I can run this application just fine from my own machine. It
| runs just fine when I move it to the server and if I run the application
| while logged on to the server.
| However, when I set the job to run as a scheduled job, I get an access
| violation error when I attempt to create the excel object within my code.
| So I am guessing that there must be something I am missing about how to
set
| the job to run on my server. Any ideas?

What is the user identity of the scheduled job?
Could you post the exact exception message?

Willy.
 
N

Nicholas Paldino [.NET/C# MVP]

What did you increase the assembly trust to?

You definitely need unmanaged code permissions.

Also, like Willy stated, what is the exact error?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jim Heavey said:
Well, I went to the .Net Configuration 1.1 and click on "Runtime Security
Policy" and then selected "Increase Assembly Trust" and from there I
selected
my application (.exe) and then indicated that it should be fully trusted.

I then ran my application with the same results.


Nicholas Paldino said:
Jim,

When .NET runs an assembly that is loaded from the network, it is
loaded
with a limited set of permissions, because it is not sure if it should be
trusted or not.

What you need to do is go to the "Microsoft .NET <x.x>
Administration"
management console from the "Administrative Tools" menu on your machine.
The <x.x> is the version number of .NET that you need to configure this
for.

Once you are there, you want to configure the runtime so that your
program (identified by location, hash, or strong name) has the
appropriate
permission set. In this case, you probably need some specific database
permissions.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jim Heavey said:
I have created a console application which reads a database and creates
an
Excel file. I can run this application just fine from my own machine.
It
runs just fine when I move it to the server and if I run the
application
while logged on to the server.
However, when I set the job to run as a scheduled job, I get an access
violation error when I attempt to create the excel object within my
code.
So I am guessing that there must be something I am missing about how to
set
the job to run on my server. Any ideas?
 
G

Guest

I incressed my "trust level" to fully trusted. The full text of the error
message (unless I am missing something) is "Access is denied". I was looking
for an error code, but I see no such property for the exception object.

The user idenity which is being used to run the job is the same user (my
user id) id which runs perfectly fine when I run it logged on to the box via
Remote Connection (to my server) and run it. But again, if I run it as a
schedule job, it get the error noted above.

This same assembly runs perfectly fine in batch mode read and updating
databases, reading and writing shared drive files, but does not work when I
attempt to open the Excel object. So my guess it has something to do with
security and Excel in particular, but I do not have a clue as to what I
should look for now.

Did I read that in 2005 there is another way to create Excel files without
having to have Excel loaded on the server...or was I just dreaming?

Thanks for all of your ideas and suggestion to date....but it has not yet
solved the problem.

Any ideas as to what I should do next?
 

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