Category Archives: Books and reading stuff

AIF–post processing of incomming record

In a recent task for a customer I created a document service based on customized datamodel (build by myself). The datamodel consisted of two related tables. In these two tables I would collect incomming records from whicj I had to create CirParty entities, HRM applicants and HRM applications. This means that my datamodel would only serve the purpose of collecting the data. Then I would create some business logic to process the incoming logic. In Dynamics AX 2012 I searched for the right hookin and found that the UpdateNow method on the Axd class to fully fulfill my requirements.

I ended up with this peace of code…


class Axdegf_HRMWebRecruitment extends AxdBase






      //EG/2014.10.07/TOMPH, 00328407_3 HRMWebRecruitment—>

    AxEGF_HRMWebRecruitment            axbc_WebRecruitment;

    AxEGF_HRMWebRecruitmentAttachments axbc_Attachments;

    //EG/2014.10.07/TOMPH, 00328407_3 HRMWebRecruitment <–


PrepareForSaveExtended method (where the reference for the current record is created – marked in red):

public boolean prepareForSaveExtended(

    AxdStack                    _axBcStack,

    str                         _dataSourceName,

    AxdRecordProcessingContext  _recordProcessingContext,

    AxInternalBase              _childRecord)


    //TODO: Add code here to ensure that required fields specified in the initMandatoryFieldsMap method are sent in by the service caller.

    switch (_dataSourceName)


        // ———————————————————————-

        // Process WebRecruitment records

        // ———————————————————————-

        case #WebRecruitment_DataSourceName:


            axbc_WebRecruitment =;

            switch (_recordProcessingContext)


                //EG/2014.10.01/TOMPH, 00328407_3 HRMWebRecruitment –>

                case AxdRecordProcessingContext::BeforeChildRecordProcessed:



                        case #Attachments_DataSourceName:



                                return true;




                    return false;

                    //EG/2014.10.01/TOMPH, 00328407_3 HRMWebRecruitment <–

                // Ensure WebRecruitment record is saved

                case AxdRecordProcessingContext::AfterAllChildRecordsProcessed:

                    if (!axbc_WebRecruitment.isProcessed())


                        return true;


                    return false;


—-code left out—

UpdateNow method:

//EG/2014.09.21/TOMPH, 00328407_3 HRMWebRecruitment

//Meethod used to run busines logig before AIF ends its lifecycle

//Here we process the incoming record

public void updateNow()


    EGF_HRMWebRecruitment           egf_HRMWebRecruitment;   



    //get the current incoming record

    //egf_HRMWebRecruitment = axegf_HRMWebRecruitment.eGF_HRMWebRecruitment();

    egf_HRMWebRecruitment = axbc_WebRecruitment.eGF_HRMWebRecruitment();

    //having he incoming record – process it




UAC troubles

Working with UAC (User Access control) in relation to win vista, win7 and win server 2008 can be quite troublesome.
Yesterday we found that one our helper apps, which has a feature to start and stop services both local and remotely, didn’t work as expected. When running the application in elevated mode, everything worked fine.
Since we can’t expect all users to remember to run the application in elevated mode, we needed to find a more permanent solution.
I have previously been working with UAC problems relating to processes not running in elevated mode, but i didn’t know how to force the entire application ro run in elevated mode. Google turned out to be my friend again and I found tons of articles telling me “just” to add a manifest file changing the existing:
<requestedExecutionLevellevel=asInvokeruiAccess=false />


<requestedExecutionLevellevel=requireAdministratoruiAccess=false />

Simple one would think – and it was, so You might figure my level of frustration, when this turned out not  to be enough.

Actually there was nothing wrong with the suggested solution, but all post that I read, failed to explain how to tell Visual Studio to use the added manifest file – I had to figure that out myself. A complete solution on how to force Your application to always run in elevated mode wil be listed here:

  • In Visual Studio 2010 (I guess the same applies to VS2008, but I haven’t tested it) right click Your project and select “add new item”
  • Add a application manifest file – the default name will be app.manifest.
  • Inside the manifest file, change the existing configuration from
    <requestedExecutionLevellevel=”asInvoker”uiAccess=”false” />
    <requestedExecutionLevellevel=”requireAdministrator”uiAccess=”false” />
  • Save and close the manifest file.
  • Please note that Your manifest file won’t show up anywhere in your solution. In order to fix that, in solution explorer, click the “show all files” button.
  • Important: Right click the manifest file and add it to the project – we need that in order to tell VS to use the manifest file when compiling our application.
  • Right click Your project and select “properties”.
  • On the application tab, the bottom section, select the manifest file:

    manifest file selection

    manifest file selection

  • Compile and run the application. If Your UAC settings are enabled, You will be prompted to allow the application to start in elevated mode.

Sometimes it can come in handy to check whether Your application is actually running in elevated mode or not. Maybe You will find this codesnippet usefull:

 WindowsPrincipal myPrincipal = new WindowsPrincipal (WindowsIdentity .GetCurrent());

 if (myPrincipal.IsInRole(WindowsBuiltInRole .Administrator) == false )
  //show messagebox - displaying a messange to the user that rights are missing
  MessageBox .Show("You need to run the application using the \\"run as administrator\\" option" , "administrator right required" , MessageBoxButtons .OK, MessageBoxIcon .Exclamation); 
  MessageBox .Show("You are good to go - application running in elevated mode" , "Good job" , MessageBoxButtons .OK, MessageBoxIcon .Information);

You may also find these references helpfull:

Very helpful blogpost on debuggig AIF services on a server 2008


Interesting whitepaper on sharepoint load testing using The Visual Studio Test Capabilities

Check out this whitepaper – How to Configure a Stress Test Project for Microsoft Office SharePoint Server 2007 using Visual Studio Team Suite 2008.

I have experienced some availabilty problems with the link, and because of that, You will also be able to get a local copy of the whitepaper from here:



If you want more information on VS and testing, You should check out the blog of Ed Glas


SAMSUNG UE46D8005 struggles part 1 – missing DR HD channel

Recently I had the pleassure to set up a brand new samsung ue46d8005 tv for a friend. It turned out to be quite a struggle with various kinds of challenges. Ofcourse I quickly turned to google where I am used to find the answer for almost anything but in this case I found it surprisingly hard. This post is created to help others facing the same or similar struggles…

My first challenge was to find all the digital channels. First of all the e-manual is not very useful since setting up your tv for digital channels reception varies depending on your cable tv supplier. In my case I am using AN-TV (denmark). I quickly found my way around in the menues and performed an auto search. Surprisingly I did not find a single channel. Having double checked the connection I turned to the options for the channels search. Strangely enough I found that I had to change the network to “SMARTV network” . Suddenly a whole bunch of digital channels were found BUT not DR HD.  I did tons of other channel searches – still no DR HD. I even tried to change the settings according to my cable tv supplier –

In my search for an explanation I stumpled accross a silly solution from somebody who claimed that changing the languange of the digital channel from danish to finnish would solve the issue. In my desperation I tried this, did another channel search and KAPOW there was all the missing channels.

The reason why this is working is apparently that when the country is set to Denmark, not all frequencies are searched. Changing the language into finnish solves this. Why this is designed so by Samsung is a mystery to me, but the most important thing is that it now is working.

So… if you are facing some problems in finding channels on your brand new Samsung LED tv just go ahead and change the language for the digital channel (not to be mistaken for the language for the entire tv) into finnish, do another channel search – that’s it.
(You will need af pincode to change the language – just type in 0000 (4 zeroes))


Free e-books

Som free e-books that I stumbled accross in the latest edition of the MSDN Flash:

Foundations Of Programming

The Foundation Of Programming Series Free e-book By Karl Seguin. It is simple, short and sweet. Especially for ‘casual’ programmers, this will give a better thought process – that’ll definitely enable them to code better and think better. This book covers the ALT.NET Philosophy, Domain Driven Development concepts, DI, TDD etc in a nice way.

Microsoft Application Architecture Guide, 2nd Edition

Published by Microsoft, this is an essential read for any Microsoft.NET developer or Architect to understand the underlying architecture and design principles and patterns for developing successful solutions on the Microsoft platform and the .NET Framework. This guide neatly covers popular architecture patterns, best practices and common challenges you need to understand for developing .NET applications. Get a good grip on developing enterprise applications in .NET.

Rob Miles C# Yellow Book 2010

A nice action packed book that takes you through C# and .NET concepts. This book explains C# language and .NET library in general – with a clear focus on implementation thought process and best practices.

Threading in C#

A short, neatly written book from Joe Albahari about Threading in C#. This is a must read for any .NET programmer to understand more about threading in general, thread pooling, synchronization, Non blocking synchronization, etc. In this book, Joe even covers the Parallel Framework Extensions and Parallel programming in .NET

Improving .NET Application Performance and Scalability

This guide is again from Microsoft, and focuses on designing your applications with Performance and scalability in mind. It has sections relevant to architects, developers, testers, and administrators. Following the checklists and guidance in this book will ensure that there won’t be any unpleasant surprises in the end. Read this guide if you develop Enterprise applications in .NET

Applying Design Patterns

This is a quick introduction towards the thought process of applying design patterns. The objective of the book is to introduce design patterns in a simple way, so that developers can understand some common patterns and how to apply them.

RefCardz from DZone

DZone has a number of awesome Ref Cardz (Quick reference sheets) on multiple technologies. You can go to DZone –> RefCardz to browse and download them (after getting a free DZone Id). Here are some of my favorites: