Request for permission of the type 'System.Security.Permissions.RegistryPermission...' failed

B

Bryan Dickerson

The full message is:

Request for permission of the type
'System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

It happened while trying to execute a small program, from a network share,
that will tests the correct installation of some ODBC/OLE drivers. It opens
a specific registry key with My.Computer.Registry.LocalMachine and then does
a quick SQL query via OLE drivers against a table in the company database.
I copied all three items in the \bin directory of the project to the network
share expecting that it would need all of them to run. So what is the error
message telling me??

TIA!
 
B

Bryan Dickerson

I forgot to add that I'm using VS 2005, but perhaps that's evident from the
"My." object. Does anyone have any ideas??
 
V

VJ

You can't do that.. When a assembly runs of the network, its not in
full-trusted mode, like running locally. Also, you don't have registry
access when running from a limited user XP Account.

Vijay

Bryan Dickerson said:
I forgot to add that I'm using VS 2005, but perhaps that's evident from the
"My." object. Does anyone have any ideas??
 
B

Bryan Dickerson

So, do I just need to go back to using the Windows Shell API to read the
registry (seems a pity)? Or how do I attain "full-trusted mode" from a
Network share?

VJ said:
You can't do that.. When a assembly runs of the network, its not in
full-trusted mode, like running locally. Also, you don't have registry
access when running from a limited user XP Account.

Vijay
 
V

VJ

I am not really sure, I just have knowledge, have not implemented any
code.... But I believe you have to use some class from System.Security
namespace. for it... Check http://www.codeproject.com. You might find some
samples there.. or try Google it... or using Shell API is the other
option..., even so I am not sure you can get a trusted access from within a
..NET assembly...

I assume that you are keeping some settings for your application, try
keeping them in local file that goes along with the APP, but if you are
reading the registry for ODBC settings, then I don't know of a better way to
do that. You can check any of the above resources mentioned above

Vijay
 
B

Bryan Dickerson

Anyone else got any ideas?

VJ said:
I am not really sure, I just have knowledge, have not implemented any
code.... But I believe you have to use some class from System.Security
namespace. for it... Check http://www.codeproject.com. You might find some
samples there.. or try Google it... or using Shell API is the other
option..., even so I am not sure you can get a trusted access from within a
.NET assembly...

I assume that you are keeping some settings for your application, try
keeping them in local file that goes along with the APP, but if you are
reading the registry for ODBC settings, then I don't know of a better way
to do that. You can check any of the above resources mentioned above

Vijay
 
P

Phill W.

Look into Code Access Security Policies (CASPOL).

You can set up areas of your network from which you "trust" .Net code as
though it were on your local machine and, therefore, with all the
permissions you require.

IIRC, VS2005 has some Whizzo tools for working out exactly what
permissions your application(s) require but, where I am, just picking a
known network location and granting "Full Trust" to it works quite nicely.

HTH,
Phill W.
 
B

Bryan Dickerson

Thanks for your response. So would I have to setup the security on every
machine that runs it? At least for the first time it's invoked?
 

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