How to integrate in Silverlight ?
To integrate VG in silverlight application/site, You have to:
- Add the assemblies of Visual Guard as references of your project.
- Add an authentication service.
- Modify the “web.config” or the “app.config” file of your application to
integrate the Visual Guard module. - Integrate Visual Guard in the code of your application.
- Create a Visual Guard repository and declare your application by using the
Visual Guard console. This repository will contain all security items (users,
roles, permissions …) of your application. - Allow anonymous sessions,
- Generate the Visual Guard configuration
files by using the Visual Guard console. These configuration files will be
needed to connect your application to the repository. - Grant read/write permissions to the repository.
Referencing Visual Guard assemblies
- Opens the solution of your project in Visual Studio.
- In the solution explorer, expands the project node.
- Right-click the Project node for the project and select
Add Reference
from the shortcut menu. - In .Net tab, select the 5 assemblies
- Novalys.VisualGuard.Security
- Novalys.VisualGuard.Security.WebForm
- Novalys.VisualGuard.Security.WebService
- Novalys.VisualGuard.Security.<RepositoryType> (Files, SQLServer or Oracle)
- Novalys.VisualGuard.Security.<ApplicationFrameworkType> (Depending on type of application’s framework, whether .NetFramework or .NetCore)
And, then click the Select button, and then click the OK button
![]() |
---|
In the list of assemblies, Visual Studio can display different versions of the Visual Guard assemblies. You must select the assembly corresponding to the version of the framework used in your project. |
![]() |
---|
You must add either Novalys.VisualGuard.Security.NetFramework or Novalys.VisualGuard.Security.Core (Depending on type of application’s framework) |

- Novalys.VisualGuard.Security contains the main Visual Guard classes.
- Novalys.VisualGuard.Security.Files contains the classes needed to access
to a file based repository. - Novalys.VisualGuard.Security.SQLServer contains the classes
needed to access to a repository stored in a Microsoft SQLServer database
(SQLServer 2000 or higher). Available only in Visual Guard Enterprise Edition - Novalys.VisualGuard.Security.Oracle
contains the classes needed to access to a repository stored in an Oracle
database (8i or higher). Available only in Visual Guard Enterprise Edition - Novalys.VisualGuard.Security.WebForm contains the classes
needed to ASP.Net application. You must reference this assembly in ASP.Net
WebSite or ASP.Net WebService project. - Novalys.VisualGuard.Security.WebService contains the classes
needed to application hosting WCF services. You must reference this assembly in
all project hosting WCF service contains the classes needed to application
hosting WCF services. You must reference this assembly in all project hosting
WCF services that needs to be secure by Visual Guard. - Novalys.VisualGuard.Security.NetFramework contains all classes required to support .Net Framework applications.
This assembly is needed only if you want to integrate Visual Guard in .net framework applications. - Novalys.VisualGuard.Security.Core contains all classes required to support .Net Core applications.
This assembly is needed only if you want to integrate Visual Guard in .net core applications.
Create an authentication service
- Add New Item,
- Select Text File
- And call it “AuthenticationService.svc”

<%@ ServiceHost Language="C#" Service="System.Web.ApplicationServices.AuthenticationService" %>;
Modifying the “app.config” or “web.config” file of your application
Add the authentication service
<system.serviceModel> <services> <service behaviorConfiguration="AuthenticationServiceTypeBehaviors" name="System.Web.ApplicationServices.AuthenticationService"> <endpoint binding="basicHttpBinding" bindingConfiguration="userHttp" bindingNamespace="http://asp.net/ApplicationServices/v200" contract="System.Web.ApplicationServices.AuthenticationService" /> </service> </services> </system.serviceModel>
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="userHttp"> <security mode="None"> <transport> <extendedProtectionPolicy policyEnforcement="Never" /> </transport> </security> </binding> </basicHttpBinding> </bindings> </system.serviceModel>
<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="AuthenticationServiceTypeBehaviors"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> </serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> </system.serviceModel>
<system.web.extensions> <scripting> <webServices> <authenticationService enabled="true" requireSSL="false"/> </webServices> </scripting> </system.web.extensions>
Configuring User Name Authentication
<authentication mode="Forms"/>
Configuring VGHTTPModule
- Add the following line of code in the <HttpModules> node.
<add type="Novalys.VisualGuard.Security.WebForm.VGHttpModule,Novalys.VisualGuard.Security.WebForm" name="VGModule"/>
<configuration> <system.web> ... <httpModules> <add type= "Novalys.VisualGuard.Security.WebForm.VGHttpModule,Novalys.VisualGuard.Security.WebForm" name="VGModule"/> </httpModules> ... </system.web> </configuration>
Configuring Membership
<configuration> <system.web> ... <roleManager defaultProvider="VGRoleProvider" enabled="true"> <providers> <add name="VGRoleProvider" type="Novalys.VisualGuard.Security.WebForm.VGRoleProvider, Novalys.VisualGuard.Security.WebForm" /> </providers> </roleManager> ... <membership defaultProvider="VGMemberShipProvider"> <providers> <add name="VGMemberShipProvider" type="Novalys.VisualGuard.Security.WebForm.VGMemberShipProvider, Novalys.VisualGuard.Security.WebForm" /> </providers> </membership> ... </system.web> </configuration>
Call the authentication service in Silverlight
- Add the Authentication service in your Silverlight application,
- call the login methode.
Add the authentication service in your project
- Right click in the project,
- Select “Add service References”,
- Put the adress of the Authentication Service,
- Select The service,
- Rename the service,
- Click on “OK”

Modify your Login Page
AuthenticationServiceClient client = new AuthenticationServiceClient(); client.LoginAsync(userName.Text, PassWord.Password, "", true); //Authenticate the user client.LoginCompleted += new EventHandler <LoginCompletedEventArgs>(client_LoginCompleted);
Modifying the “app.config” or “web.config” file of your application
- Configure the authentication mode,
- Configure the HTTModule
Configuring User Name Authentication
<authentication mode="Windows"/>
Configuring VGHTTPModule
Create a service “VGService”
//-------------------------------------------------------- //Methode: GetAllPermission //This methode is use to have the list of all permissions of the connected user //-------------------------------------------------------- [OperationContract] public List<VGPermission> getAllPermissions() { return VGHelper.GetAllPermissions(VGSecurityManager.Runtime.Principal); }
Configure the service in the web.config file
<configuration> <system.serviceModel> <services> <service behaviorConfiguration="VGSecurityBehavior" name="CalculatorService"> <endpoint binding="basicHttpBinding" contract="ICalculatorService" /> </services> .... </system.serviceModel> </configuration>
Adding a new service behavior
<configuration> <system.serviceModel> </behaviors> <behavior name="VGServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </behaviors> </system.serviceModel> </configuration>
Integrating Visual Guard in your WCF Silverlight code
- When you want to restrict the access of a service to a caller
- When you want to apply security actions on a WebService, a custom class or
custom control, you must call Visual Guard to set the security of this object. - When you want to check if a user has a specific permission or a specific role,
in this case you can use
VGSecurityManagerPrincipal
Restricting the access to a service
[VGPrincipalPermission(SecurityAction.Demand, Name="CanMultiply", Type=VGPermissionType.Permission)] public double Multiply(double n1, double n2) { return n1 * n2; }
<VGPrincipalPermission(SecurityAction.Demand, Name:="CanMultiply", Type=VGPermissionType.Permission)> _ Public Function Multiply(Double n1, Double n2) As Double Return n1 * n2 End Function
Securing objects of the application
- Add the
Novalys.VisualGuard.SecurityVGISecurable interface to your class. - Add the call to the
SetSecurity method at the end of the constructor.
public class Calculator: ICalculator, VGISecurable { public Calculator() { // .... // Initialization of the object // .... // This call will indicates to Visual Guard that the class must be secured. VGSecurityManager.SetSecurity(this); } public double Multiply(double n1, double n2) { return n1 * n2; } }
Public Class Calculator Implemenents ICalculator, VGISecurable Private Sub New() ' ... ' Initialization of the object ' ... ' This call will indicates to Visual Guard that the class must be secured. VGSecurityManager.SetSecurity(Me) End Sub Public Function Multiply(ByVal n1 as Double, ByVal n2 as Double) As Double Return n1 * n2; End Function End Class