Visual Guard Class Library Documentation

Debugging Visual Guard Security Actions

When you launch in debug mode your application from Visual Studio, Visual Guard generates automatically a trace indicating the roles and permissions granted to the current user and the status of the execution of Visual Guard security actions. You can consult this trace in 'Output' view of Visual Studio (Menu View > Output).

This trace can help you to answer the following questions:

Here is a sample of trace generated by Visual Guard:

Visual Guard: *******************************************************
Visual Guard: ==> 2006-08-23 13:27:22Z: Visual Guard initialization
Visual Guard: ==> 2006-08-23 13:27:23Z: Repository provider loaded: Novalys.VisualGuard.Security.Files.Repository.VGFileRepositoryConnection, Novalys.VisualGuard.Security.File, Version=2.5.708.6, Culture=neutral, PublicKeyToken=8e423a8f05ffd0dc
Visual Guard: Authorization attempt: user=jsmith (status=Success)
Visual Guard: Granted Role: #Sales manager (#Sales manager)
Visual Guard:     Granted permissions:
Visual Guard:         [Sales manager permissions].\Employees\Disable employees edition (id=8f95817d-ac24-4fd1-90d7-49a42eacd156)
Visual Guard:         [Sales manager permissions].\Products\Disable products and categories edition (id=bb241aa9-24ce-4b5b-96d3-4bf16db4e174)
Visual Guard:         [Common permissions].\Samples\Permission with argument(MyValue = My default value) (id=07b21eb4-4bef-4a0d-83aa-adb90c31a992)
Visual Guard:         [Common permissions].\Samples\Script Action Sample(Attribute1 = "My Value for attribute1", Attribute2 = 31/12/2006 00:00:00) (id=c755dfa1-73a3-47cd-8260-b4f6c20e3018)
Visual Guard:         [Non administrator permissions].\Users\Disable Membership edition (id=042e30c2-ca0f-4ce8-931f-8290fe98417e)
Visual Guard: Authentication attempt: user=jsmith (status=Success)
Visual Guard: ==> 2006-08-23 13:27:30Z: Set Security of Novalys.VisualGuard.NorthwindSample.Common.Data.SecuredNorthwindDataset
Visual Guard: ==> 2006-08-23 13:27:30Z: Set Security of Novalys.VisualGuard.NorthwindSample.MDIForm
Visual Guard: ==> 2006-08-23 13:27:30Z: Execute Action \Products\Disable products and categories edition.MDIForm.SetProperties(_myCategories.Enabled=False,_myProducts.En...)
Visual Guard: ==> 2006-08-23 13:27:30Z: Execute Action \Samples\Script Action Sample.MDIForm.SetProperties(_editConfigToolStripMenuItem.Visible=False)
Visual Guard: ==> 2006-08-23 13:27:30Z: == Action condition 'Enabled = true' is True => Action executed
Visual Guard: ==> 2006-08-23 13:27:30Z: Execute Action \Users\Disable Membership edition.MDIForm.SetProperties(_usersMenuItem.Enabled=False)

    Granted Permissions: You can see the list of granted permissions and the value of permission arguments.

    Authentication process status: You can check why a user can’t access to the application.

    List of objects secures by Visual Guard: You can see when Visual Guard applies security actions on an object. When this line does not appears for an object, you must check whether the VGSecurityManager.SetSecurity is called for the object (see: How Visual Guard secures an application)

    Security Action execution status: You can see whether Visual Guard apply the security to an object and whether action are executed or not.

How to generate a trace in release mode 

You can also generate a trace without using the debug mode. To do that, you can use the properties VGSecurityManager.TraceLevel and VGSecurityManager.TraceListener or you can specify the tace level in the application configuration file.

The following example is added in the the Global.asax script of a website and shows how to generate a trace file 'MyTrace.Txt' at the root of the website.

void VGModule_Initialized(object sender, Novalys.VisualGuard.Security.WebForm.VGSecurityInitializedEventArgs e)
    // Trace all information in a MyTrace.txt at the root of the website 
    string path = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "MyTrace.Txt");

    System.Diagnostics.TextWriterTraceListener listener;

    listener = new System.Diagnostics.TextWriterTraceListener(new System.IO.FileStream(path, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite));

    Novalys.VisualGuard.Security.VGSecurityManager.TraceLevel = System.Diagnostics.TraceLevel.Info;
    Novalys.VisualGuard.Security.VGSecurityManager.TraceListener = listener;

The following example show how to activate the trace by setting an application configuration file:

<?xml version="1.0" encoding="utf-8" ?>
            <add name="VisualGuard" value="3" />


In this case, Visual Guard will generate the trace in the file '<system temp directory>\VGTraceOut.txt'. If you do not have enough priviliges to write or create a file in this directory then Visual Guard will not generate the trace.

Debugging dynamic script action

It is possible to use the Visual studio debugger to debug the scripts defined in a ‘Script action’. You just have to call the ‘DebugBreak’ method in the script of your action. When the script will be executed at runtime, the call to this method will signal a breakpoint to the attached debugger.

See Also

How Visual Guard secures an application

How to apply security in your application