Category Archives: XAF

A DevExpress application framework that wraps up standard application processes into modules.

.NET Applications on Linux

Well, what a touchy subject this might be to some people.  I have always seen the battle go back and forth between Windows, Macintosh and Linux.  Windows being a middle-tier price range which excellent performance, Macintosh being the high end simply from marketing and Linux being the low end cost point which the most potential.  The problem I have always seen is that Microsoft holds the middle share which is always the most used share.   I have been a Microsoft developer for my entire career and I love it to death, but the power behind a Linux machine is starting to become hard to ignore.  Recently I ran into a project that was faced with spending 100 hours developing a communication platform for a piece of software or somehow getting .NET hooked into a Linux server.

Of course we went both routes as with any project whichever option is the best is the choice, but something has to work.  I came across this plugin for Apache and Linux called Mono.  Mono is a plugin/server application that lets you run ASP.NET applications on your Linux server native.  You do not have to get pushed to another server or lose your performance, you simply install the package and configure it in Apache and you are up and running.  To start, here is the mono website for you to check out and hopefully spread out through all of your Linux servers:

Hopefully you all install it and configure it so when I come through I can install my applications on your server and be just fine and dandy, if you don’t I will no doubt make you do it :)  There is a set of install instructions for each server type including Mac servers as well as CentOS, Ubuntu, Debian, etc.  Mostly it seems to just be a package installation through w-get or whatever your package flavor is.  After configuration you can use this site to configure virtual directories:

The nice thing about this configuration generator is that you can create a separate config file for each virtual directory and include them in your base httpd config file under each virtual host settings section.  It is almost exactly like creating virtual applications in IIS and the performance is for the most part the same.  From what I have seen this far, .NET 4.0 is supported as well as AJAX, and I am hoping to see some more stuff go into the project to make it a viable option for hosting .NET applications.  Cheers!

HOW TO: Create an XtraReport from a ReportData Object

DevExpress has a nice module for their eXpressApp Framework called the Report Module.  The purpose of this module is to provide a reporting engine for your objects and allow you to generate reports through actions and in the UI.  So far, the biggest problem I have encountered with this is how to generate these reports outside of the Framework once they are designed a ready.  A typical scenario involves having a designed application and then needing to develop some sort of service process that fetches and sends reports on a daily basis.

As a work around, I’ve found out how to generate these reports as a simple XtraReport instead of a XafReport object.  The XtraReport class can be loaded from a stream which contains the layout in a byte array.  I simply read the layout from the persistent ReportData object into a byte array and load the XtraReport from it.  Here are some code examples:


Dim uowUnitOfWork As New  UnitOfWork(XpoDefault.DataLayer)
Dim obsObjectSpace As New ObjectSpace(uowUnitOfWork, XafTypesInfo.Instance)
Dim rptReportData As Reports.ReportData
Dim xfrReport As Reports.XafReport

rptReportData = obsObjectSpace.FindObject(Of Reports.ReportData)(Nothing)
xfrReport = rptReportData.LoadXtraReport(obsObjectSpace)


using( UnitOfWork uow = new UnitOfWork( XpoDefault.DataLayer ) ) {
        ObjectSpace objectSpace = new ObjectSpace( uow , new XpoTypesInfoAdapter(
uow.DataLayer.Dictionary ) );
        ReportData reportData = objectSpace.FindObject<ReportData>( new BinaryOperator( "Name",
"ContactsGroupedByPosition" ) );
        if( reportData != null ) {
            XafReport report = reportData.LoadXtraReport( objectSpace );
            report.ObjectSpace = objectSpace;

HOW TO: Set Properties Dynamically Using XAF/XPO

XPO provides some very powerful features which are wrapped up again in a nice library for XAF. One such feature is the System.Reflection metadata that is wrapped into a nice library that allows you to find attributes easier etc. I recently came across a situation which required me to set an unknown property with an unknown value and show any errors if the typing didn’t work or the property wasn’t found. To do this, I used the XafTypes Instance of XAF to find the type and member info. The code looked something like this:

Dim dtiTypeInfo As TypeInfo
dtiTypeInfo = XafTypesInfo.Instance.FindTypeInfo(GetType(ObjectType))
If dtiTypeInfo Is Nothing Then
    Return Nothing
End If
Return dtiTypeInfo.FindMember(MyFieldName)

The next challenge I ran into was deserializing the values of the object, which again XAF and XPO provide a nice wrapper to forget about all of the noise. I simply used the deserialize method of the member info that I just returned and passed in the string value that I wanted to set. This automatically converted everything to what I need and also allows you to serialize down properties into databases if you wanted to and set properties based on their deserialized value. This was a one liner that looks like this:


XAF Security System & Roles

The standard security system in XAF does not support anonymous content out of the box. Everyone is a registered user and requires registration straight out of the gate. We have been working on products lately that require a more user friendly approach to web logins.

One of the ways we came up with was creating using a multi-tier security system concept. This has multiple user objects allowing for a single base user to define standard access, and users on top of it to dictate how the specific application is working.

To use this concept, we replaced the security system with a few lines of code:

Security Class:

Public Class AnonymousSecuritySystem
    Inherits DevExpress.ExpressApp.Security.AuthenticationActiveDirectory

    Protected Overrides Function GetUserName() As String
        Return "Anonymous"
    End Function
End Class

After replacing the security system, we created a controller which allows a user to login based on another tier object.

Public Class LoginController
    Inherits DevExpress.ExpressApp.ViewController

    Public Sub New()

        'This call is required by the Component Designer.
    End Sub

    Private Sub Login_Execute(ByVal sender As System.Object, ByVal _ 
             e As Actions.SimpleActionExecuteEventArgs) Handles Login.Execute
        Dim oWebUser As WebUser = ObjectSpace.FindObject(Of WebUser) _ 
             (CriteriaOperator.Parse("UserName = 'a'"))
        If oWebUser IsNot Nothing Then
            CType(SecuritySystem.Instance, SecurityComplex).Logon(oWebUser.BaseUser)
        End If
    End Sub
End Class

This is extended out to each application, so we can have separate win and web users, as well as keeping the option open to share the same roles between the applications.