C
Carl Johansson
I think I'm going nuts! I have a perfectly fine exe assembly built with
Microsoft Visual C# 2008 Express Edition. When executed from my local hard
drive it runs as exactly as expected. However, when trying to launch it from
a network drive it just won't run. One suggestion I saw was to start the
"Microsoft .NET Framework 1.1 Wizards" and run "Trust an Assembly". However,
after having browsed to the assembly the wizard simply reported that it
wasn't possible to load the assembly. So I continued my search and added
this to the AssemblyInfo.cs file of my project:
[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, ViewAndModify =
"*")] // Request complet access to the registery key
[assembly: ZoneIdentityPermission(SecurityAction.RequestMinimum, Zone =
SecurityZone.NoZone)] // Request unrestricted zone
I then recompiled the project (had to add the namespaces
"System.Security.Permissions", "System.Security.Policy", and
System.Security), copied it to the network drive, and tried the Microsoft
..NET Framework 1.1 Wizards again. Same result: "not possible to load the
assembly".
I realize this is a .NET security issue, but there must be some easy to
understand way to get this working, or at least some tutorial that can
explain what needs to be done. The assembly "talks" to a SQL Server 2000
server on the network, and works perfectly fine when executed from a local
hard drive on any computer in the network.
Regards Carl Johansson
Microsoft Visual C# 2008 Express Edition. When executed from my local hard
drive it runs as exactly as expected. However, when trying to launch it from
a network drive it just won't run. One suggestion I saw was to start the
"Microsoft .NET Framework 1.1 Wizards" and run "Trust an Assembly". However,
after having browsed to the assembly the wizard simply reported that it
wasn't possible to load the assembly. So I continued my search and added
this to the AssemblyInfo.cs file of my project:
[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, ViewAndModify =
"*")] // Request complet access to the registery key
[assembly: ZoneIdentityPermission(SecurityAction.RequestMinimum, Zone =
SecurityZone.NoZone)] // Request unrestricted zone
I then recompiled the project (had to add the namespaces
"System.Security.Permissions", "System.Security.Policy", and
System.Security), copied it to the network drive, and tried the Microsoft
..NET Framework 1.1 Wizards again. Same result: "not possible to load the
assembly".
I realize this is a .NET security issue, but there must be some easy to
understand way to get this working, or at least some tutorial that can
explain what needs to be done. The assembly "talks" to a SQL Server 2000
server on the network, and works perfectly fine when executed from a local
hard drive on any computer in the network.
Regards Carl Johansson