Security Settings

PowerBuilder applications and components can run in partial trust environments when they are constrained by .NET code access security (CAS) configurations.

PowerBuilder lets you configure CAS security zones (sandboxes) for .NET Web Service projects, to minimize the amount of trust required before application or component code is run by an end user.

For .NET Web Service projects, you can also modify the Web.config file to support security zones after you deploy the project. The .NET assemblies that you create by building and deploying .NET Assembly projects are run with the security permissions of the calling application or component.

Permission error messages

If your .NET Assembly or Web Service attempts to perform an operation that is not allowed by the security policy, the Microsoft .NET Framework throws a runtime exception. For example, the default local intranet trust level has no file input or output (File IO) permissions. If your application runs with this security setting and tries to perform a File IO operation, the .NET Framework issues a File Operation exception.

You can catch .NET security exceptions using .NET interoperability code blocks in your PowerScript code:

   #if defined PBDOTNET then     
         ClassDefinition cd_windef
         cd_windef = FindClassDefinition("w_1")
         messagebox("w_1's class
	      catch(System.Security.SecurityException ex)
	      end try
   #end if

All .NET targets must include a reference to the mscorlib.dll .NET Framework assembly in order to catch a System.Security.SecurityException exception. PowerBuilder .NET Web Service components generate PBTrace.log files that log critical security exceptions by default.

If you do not catch the exception when it is thrown, the PowerScript SystemError event is triggered.

Debugging and tracing with specified security settings

You can debug and run .NET Assembly or Web Service from the PowerBuilder IDE with specified security settings. (The CAS settings generated in the Web.config file determine the security permissions used by .NET Web Service components.)

If your .NET Assembly or Web Service attempts to perform an operation not allowed by the specified security setting, an exception is issued in the IDE.