Install a Windows Application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have to put my Program EXE in a server share, but when I try to open the program a "System.Security.SecurityException" occures
If I open my program in my computer no error occures..
Any clue

Thanks for your help
 
When a .NET program is run from a remote server (the EXE is located on a
remote server) it runs under the "Local Intranet" zone, which means that it
does not have permissions to execute all calls. Use the caspol to give the
application more permission.

Arild

Bernardo said:
Hi,

I have to put my Program EXE in a server share, but when I try to open the
program a "System.Security.SecurityException" occures!
 
I've seen this problem when running a .NET application from a network
share. If you run the application locally (from your own machine) then
you don't get this error. I believe the cause of this error has to do
with two things:

1) The security context that was set for .NET applications on the local
machine (which is configurable)

2) The application itself was not designed to be run from a network
share (normally you don't have to worry about this with "regular" MFC or
WIN32 apps but with .NET, security is a whole new animal so...)

The easy way out would be to look at (1) and configure your local .NET
security context to allow running apps from network shares. Please note
I've never actually attempted to do this, I just end up copying the app
locally to my machine.

If you get it working other than what I've done please let me know (to
confirm that what I said is true).
 
I have to put my Program EXE in a server share, but when I try to open the
program a "System.Security.SecurityException" occures!
If I open my program in my computer no error occures...
Any clue?
Microsoft added these security settings to reduce misuse of software by
hackers.

Two things must be set:
* First you must tell the compiler that this program you created will use
Network access.
Default, .NET does not allow an executable to access network resources
(including open file dialog)
One way is to this can be done is by putting lines like these into you
assembly.cs:

[assembly:SecurityPermission(SecurityAction.RequestMinimum,
UnmanagedCode=true)] // Request to run unmanaged code
[assembly:FileIOPermission(SecurityAction.RequestMinimum,
Unrestricted=true)] // Request complete File IO functionality
[assembly:RegistryPermission(SecurityAction.RequestMinimum, All="*")] //
Request complet access to the registery key
[assembly:ZoneIdentityPermission(SecurityAction.RequestMinimum,Zone=Security
Zone.NoZone)] // Request unrestricted zone

* Second even if the program is allowed to run from network drives or open
files on network drives, the big boss of the computer that will run this
code on, must give enough rights to the program to actually run from network
or open network files. If you go to "control panel", "Choose Administrative
Tools", then you find something like "Microsoft .NET Framework 1.1 Wizards".
Double click on that and go to "Trust an assembly" and set the settings for
your program with your key (+strong name) to be fully trusted. An option to
change the trust "Adjust .NET security" for "Local intranet" might also be
put to fully trusted, but this is not wise to do so since you then accept
all .NET programs to run unrestricted.


In my opinion, generate a strong key (some program called sn.exe if I
remember correctly) ,
add this to your program BUT DO NOT DISTRIBUTE THIS TO OTHERS!
--> assembly.cs : [assembly: AssemblyKeyFile("..\\..\\MyKey.snk")]

Then you can tell the "Microsoft .NET Framework 1.1 Wizards". that all
programs with this strong key, ignoring assembly the version, are fully
trusted.
This way, you only have to register this once, and all your future upgrades
or other products with this key, will automatically be trusted for network
access.

It would be desirable that the security settings were not fixed in the
assembly.cs, but generated dynamically when needed.
Maybe other people have different techniques?

Hope this helps?
 
Back
Top