Logging independently of transaction scope by using a separate thread in Dynamics AX (deux)

 
Good evening
 
Michal Kupczyk from this thread on the Microsoft communities proposes a much better way to log independantly of transaction scope in Dynamics Ax than what I had originally proposed here. Instead of using a separate thread to log, is uses a UserConnection object.
 
In addition to being simpler, it also has the added value of working from within batches. Batches it seems don’t support multithreading.
 
void method()
{
    UserConnection conn = new UserConnection();

    yourLogTable = null;
    yourLogTable.setConnection(conn);

    ttsbegin;

    […]
    yourLogTable.Log = ‘This is tts-independent log’;
    yourLogTable.insert();

    if (some_error)
    {
        throw Error(‘Error in processing’);
    }

    ttscommit;
}

Posted in Dynamics AX 2009 | Comments Off on Logging independently of transaction scope by using a separate thread in Dynamics AX (deux)

Dynamics AX 2009 SSRS and SSAS Integration Tips

 
Good morning
 
Here’s a good list of Resources and Known Issues for SSRS report deployment and Role Centers under Enterprise Portal in AX 2009, for those with access to PartnerSource you can find the original here (link on PartnerSource):
 

Resources

 

Known Issues and Solutions

This section lists the most common issues encountered when building the integration between Microsoft Dynamics® AX, SSRS and OLAP and the solution recommended by the Microsoft Dynamics® AX Support team.

Issue:

Error trying to deploy reports
Microsoft Dynamics AX Reporting Project Deployment: The following components have not been installed or are not configured correctly: AL.exe

Solution:

Download and install the Windows SDK for Windows Server 2008 and .NET Framework 3.5  Ensure it is fully installed.
NOTE:  Install regardless of operating system

Issue:

Error trying to deploy reports
System.InvalidOperationException: The following components have not been installed or are not configured correctly: Microsoft Domain-Specific Language Tools

Solution:

Download and install these required components.  Microsoft Visual Studio 2008 Shell (isolated mode) Redistributable Package

  1. Save the download locally
  2. Extract the package
  3. Run the vs_appenvredist.msi

NOTE:  Install regardless of operating system

Issue:

Error trying to deploy reports
Microsoft Dynamics AX Reporting Project Deployment: ClrBridgeLoader: fatal error :
Microsoft.Dynamics.ClrBridge.dll cannot be loaded. Fatal error: ClrBridge is note loaded.

Solution:

Ensure you are trying to deploy reports from the SSRS server and that you can validate the SSRS server name in the Reporting Servers from within Microsoft Dynamics AX 2009.  If this error appears right after installing the reporting extensions, launch the report deployment tool again.

Issue:

Enterprise Portal (EP) or SSRS Reports don’t run or stop working
An attempt has been made to use a data extension ‘AXDATAMETHOD’ that is not registered for this report server. (rsDataExtensionNotFound)
or
data extension ‘AXQUERY’ and ‘AXADOMD’

Solution:

Installing or Reinstalling Reporting Extensions will resolve this issue.  As a precaution make a Backup of:
Program Files\Microsoft SQL Server\MSSQL.<Instance>\Reporting Services\ReportServer folder

NOTE:  SSRS updates or Service Packs may remove entries from rsreportserver.config file.

Issue:

Enterprise Portal (EP) Reports don’t run or stop working
A ProgressTemplate must be specified on UpdateProgress control with ID ‘AxProgressControl’

Solution:

You can resolve the issue by using one of the three methods below:

  1. Apply the hotfix from KB957312 to the RTM version
  2. Upgrade to Dynamics AX 2009 SP1
  3. Un-install Microsoft .NET 3.5 SP1 and reinstall Microsoft .NET 3.5 without SP1

Issue:

Report deployment tool Crashes
Attempted to read or write protected memory.  This is often an indication that the memory is corrupt

Solution:

If multiple versions of Dynamics AX are installed on the same server you will need to change your AX 2009 Path in your environment variables ahead of your AX 4.0 path to avoid running the wrong version of DLL’s

Issue:

Error running reports
Error during processing of ‘AX_CompanyName’ report parameter. (rsReportParameterProcessingError).

Solution:

Process OLAP the cubes to supply data to the reports
or
An incorrect Execution account has been specified in the Reporting Services Configuration Manager

Note:  For SSRS 2008 the BC proxy is required to be the Execution account and for SSRS 2005 an Execution account should not be used.  Also look at application event log for details on other issues.

Important:  Running SSRS in SharePoint integrated mode is not support with Microsoft Dynamics AX

Issue:

Enterprise Portal (EP) web site runs but not the reports in the EP web parts:
Dynamics Adapter LogonAs failed
or
Microsoft.Dynamics.BusinessConnectorNet.LogonFailedException

Solution:

Leave the Execution account blank on SSRS 2005 or set to BC Proxy account on SSRS 2008 (Microsoft Dynamics AX 2009 SP1 only)

NOTE:  SSRS Execution account is set to an account other than BC Proxy Account

Issue:

EP or SSRS Reports don’t run or stop working
Dynamics Adapter LogonAsGuest failed
or
FatalSessionException…

Solution:

The issue is caused by the Reporting Services web site set to anonymous Authentication.  Changing the SSRS website to Integrated and/or un-marking Anonymous Authentication will resolve this issue.

Issue:

Double Hop \ Kerberos Authentication
An Error has occurred while establishing as connection to the Analysis Server
or
Reports don’t display in the EP website from a Client Browser not local to the IIS server
Cannot read information from SQL Server Reporting Services. Validate that the Report Manager URL is correct

Solution:

Setup Service Principle names (SPN) and Delegation to allow the passing of Kerberos certificate

References:
White Paper:  Configuring Kerberos Authentication with Role Centers
KB917409:  How to configure SQL Server 2005 Analysis Services to use Kerberos authentication
MSDN blog:  Enterprise Portal Kerberos Delegation for connecting to Reporting/Analysis Services on a different box
TechNet blog: Understanding Kerberos Double Hop
TechNet webcast: How to understand, implement, and troubleshoot Kerberos double-hop authentication

Issue:

Office Data Connection (ODC) file deployment fails with SQL Server 2008
Microsoft Dynamics AX is searching for the SQL Server 2005 Microsoft.AnalysisServices.dll (v9.0.242.0)

Solution:

Apply one of the following hotfixes:

  • For Microsoft Dynamics AX 2009 RTM:  Apply the fix from KB957312
  • For Microsoft Dynamics AX 2009 SP1:  Apply the fix from KB960158

If the hotfix does not resolve the issue, make sure you are running a Dynamics AX 2009 client on the EP web server when deploying the ODC files.  As a workaround you can manually deploy the ODC files by following these steps:

  1. Click here to download a new ODC file (Dynamics_AX.odc).
  2. Save the ODC on the SSAS server
  3. Open the ODC file with Notepad or any other text editor
  4. Edit the odc file with the following changes:
    Data Source=OLAPServerName
    Initial Catalog=OLAPDbName
    Add SSPI=Kerberos after Initial Catalog if using Kerbersos (in red only required for Kerberos authentication)


    ….
    <odc:Connection odc:Type="OLEDB">
    <odc:ConnectionString>Provider=MSOLAP.3;Integrated Security=SSPI;Persist Security Info=True;
    DataSource=<Server1>;Initial Catalog=Dynamics AX;SSPI=Kerberos
    </odc:ConnectionString>

  5. Save the changed ODC file.
  6. Go to EP main site.
  7. Click on Site Actions > Site Settings.
  8. Under Galleries, click on Master pages.
  9. Click on View all site content (top left).
  10. Click on Data Connections folder.
  11. Import the edited ODC file.

Issue:

DataSet panel is missing in Report Designer when creating reports in Visual Studio Server 2008

Solution:

For Visual Studio 2008, apply the fix in KB947173
OR
apply Microsoft Visual Studio 2008 Service Pack 1.

Issue:

"Connection forcibly closed by remote host" in Dynamics setup log when trying to create an EP site in AX 2009

Solution:

Download and install the Microsoft Analysis Management Objects:

Issue:

"Client found response content type of ‘text/html; charset=utf-8’, but expected ‘text/xml’"

Solution:

Ensure SSRS service is running and are able to connect to instance via SQL Server Management Studio.
Note:  Additional information can be found in SSRS error log.

Issue:

Exception from HRESULT: 0X80041FFF

Solution:

Change Visual Studio project location to local drive if using a network share

Issue:

The Analysis extension is not seeing the SQL cluster name for Analysis Services when Analysis services is setup on a SQL cluster.

You will get an error similar to this when trying to install Analysis Extension in this environment:

Connecting to SQL Server 2005 Analysis Services on server ‘SQL02’ and instance ‘MSOLAP$ANALYSIS’.
A connection cannot be made. Ensure that the server is running.
No connection could be made because the target machine actively refused it 127.0.0.1:2383
An error occurred while Setup was connecting to SQL Server Analysis Services instance ‘MSOLAP$ANALYSIS’ on server ‘SQL02’.

An error occurred while Setup was connecting to SQL Server Analysis Services instance ‘MSOLAP$ANALYSIS’ on server ‘SQL02’.

Solution:

The workaround is to manually run the script to create the Dynamics AX OLAP db from the AX 2009 CD.

Navigate to this folder \support\Analysis Services\Scripts on your AX 2009 installation CD.
Then run the dynamicsax.xmla script from within SQL Management Studio (connected to the SSAS instance).

This script will create the Dynamics AX OLAP database.

Issue:

BC Proxy account fails to start for the SSRS reports in Enterprise Portal with RPC exception 5

When Enterprise Portal starts for the first time and displays SSRS reports, normally two Business Connectors are started. After a period of time or if the impersonated web user logs out for the SSRS Proxy account you may experience an RPC error 5 access denied and the SSRS reports will no longer display in Enterprise Portal.

Example
Error:

Event Type: Error
Event Source: Dynamics .NET Business Connector 5.0
Event Category: None
Event ID: 180
Date: 10/7/2008
Time: 6:21:04 PM
User: N/A
Computer: AX2009
Description:
Microsoft Dynamics AX Business Connector Session 18.

RPC error: RPC exception 5 in Ping occurred in session 36

Solution:

RPC error 5 can occur if the SSRS Execution account is set in the Reporting Services Configuration Manager. If the account used is the Business Connector proxy account the first startup of the Business Connector will work, but not any subsequent startups unless the IIS application pool if recycled or an IIS reset is done.

SSRS 2005
Remove the SSRS execution account through Reporting Services Configuration Manager

SSRS 2008
Change the SSRS service to start as the Business Connector Proxy account and remove the SSRS execution account through Reporting Services Configuration Manager.
Note:  Changing the SSRS account would require a change in the registered SPN’s if you are using Kerberos authentication

Tips and Tricks

Good luck!

Posted in Dynamics AX 2009 | Comments Off on Dynamics AX 2009 SSRS and SSAS Integration Tips

Logging independently of transaction scope by using a separate thread in Dynamics AX

Good morning,

Continuing on the topic of good ideas to palliate lazy code designs (ref: previous post on runbuf()), I wanted to discuss a possible way to write to a table from inside a TTS (between a begin and a commit) without being rolled back if an error is thrown or if a ttsabort is called.

Doing this is definitely not best practice, but it was extremely useful for me when I wanted to log information to a table from inside a TTS that would throw errors on occasion where catching was not behaving ideally because of an encompassing TTS (I’ll follow up on that on another post).

So basically, the idea I had is to launch a separate thread only for logging, this would effectively isolate the table insert from the encompassing TTS and would not be rolled back on error in the originating thread. So the logging would always occur regardless of errors.

Here’s a sample of the code:

public class LogThread
{
public server static void logThreadWorker(Thread t)
{
    LogTable log;
    ;

    [log.ParmId,
        log.XmlRequest,
        log.XmlResponse] = t.getInputParm();
    log.insert();
}
}

//Use a separate thread to survive a ttsabort
public server static void logUsingThread(
    str _parmId,
    str _xml1,
    str _xml2)
{
    Thread thread;
    ExecutePermission permission;
    ;

    permission = new ExecutePermission();
    if (!permission)
    {
        return;
    }

    permission.assert();

    // BP deviation documented.
    thread = new Thread();
    if (thread)
    {
        thread.removeOnComplete(true);
        thread.setInputParm([_parmId, _xml1, _xml2]);
        thread.run(classnum(LogThread),
            staticmethodstr(LogThread, logThreadWorker));
    }

    CodeAccessPermission::revertAssert();
}

//This method is the entry point for logging, and is called from a series of transactions and operations that might fail.
//It is called from inside a large TTS encompassing multiple business processes.
protected void log(
    MyWebservice.WebServiceWrapper _webServiceWrapper)
{
    ;

    LogTable::logUsingThread(
        this.parmId(), //I had a parmId for every request to the webService
        _webServiceWrapper.get_LastXmlRequestDoc(),
        _webServiceWrapper.get_LastXmlResponseDoc());
}

Posted in Dynamics Ax 4.0x | Comments Off on Logging independently of transaction scope by using a separate thread in Dynamics AX

Basic calculator using runbuf() in Dynamics AX

Good evening,
If you ever need to build a mathematical calculator in Dynamics AX, you might consider using runbuf() as basis for the code. The only critical considerations are to make sure that an attacker cannot use the calculator to execute code other than mathematical functions.
Here’s a quick example of what the calc() code for the calculator might look like (in a job):
public static void calcExample(Args _args)
{
    real ret;
    str formula = "(30+20)*(2)"; //user might type this into a textbox on a form
    ;
    ret = runbuf(
        strfmt(
            "real calc()\n"
            +"{\n"
            +"    ;\n"
            +"    return %1;\n"
            +"}\n", formula));

    info(SysQuery::value(ret));
}

An added advantage of using runbuf() this way, is that it gives the user the ability to use mathematical functions defined in AX like abs() acos(), asin(), atan(), etc.
Posted in Dynamics Ax 4.0x | Comments Off on Basic calculator using runbuf() in Dynamics AX

Microsoft New Orleans Convergence 2009

 
Good evening
 
I’ve finally got some time to post a quick recap of Convergence 2009. New Orleans is a great city, well on its way to returning to its former self, kudos to Microsoft for hosting Convergence there.
 
Convergence is generally geared towards PR and networking, but your run of the mill Ax Programmer guy can find a few interesting things there. I attended about half a dozen conferences, three of which were more notable. I forget the third right now, but the two I remember were given by M. Srinivasan from Microsoft. One is about the upcoming Advanced Data Management module for Ax, the other is about Performance, Sizing and Benchmarks on Ax. Here are the two powerpoints:
 
 
On another note, watch out for hurricanes in New Orleans, and no, not these hurricanes; I’m talking about Pat O’Brien hurricanes…
 
Thanks!
Posted in Dynamics AX 2009 | Comments Off on Microsoft New Orleans Convergence 2009

Dynamics Ax 2009 SSRS report deployment under Server 2008 (deux)

 
If you get the following error in the deployment log file:
 
The following components have not been installed or are not configured correctly:
AL.exe
Microsoft Domain-Specific Language Tools
 
This error message indicates that the following software components are not installed:
Windows SDK for Windows Server 2008 and .NET Framework 3.5 (only the .NET Development Tools package is required)
 
What Microsoft is not mentioning in the installation guide is that you may get these errors even if these two prerequisites are installed. This happens sometimes when you uninstall Visual Studio 2008 and replace it with these two prerequisites after having installed the .Net Business Connector.
 
It would seem that the exact installer required to fix the missing AL.exe error is contained in Visual Studio 2008 under the name of Microsoft Windows SDK for Visual Studio 2008 .NET Framework Tools. This cannot be installed individually, so I’ve extracted it from the VS 2008 DVD and made it available on SkyDrive.
 
Microsoft Windows SDK for Visual Studio 2008 .NET Framework Tools (Download links on SkyDrive):  

http://cid-d7481095c2c4b9f5.skydrive.live.com/embedrow.aspx/.Public/Ax2009files/|5×64|6MicrosoftWindowsSDKforVisualStudio2008.NETFrameworkTools.ziphttp://cid-d7481095c2c4b9f5.skydrive.live.com/embedrow.aspx/.Public/Ax2009files/|5×86|6MicrosoftWindowsSDKforVisualStudio2008.NETFrameworkTools.zip

Note that when I uploaded the files, they were virus free, however, I’m not responsible for SkyDrive.
Posted in Dynamics AX 2009 | Comments Off on Dynamics Ax 2009 SSRS report deployment under Server 2008 (deux)

Dynamics Ax 2009 SSRS report deployment under Server 2008

 
If you get the following error in the deployment log file:
 
“Deployment failed with the following exception:
System.Runtime.InteropServices.COMException (0x80040208)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Management.ManagementObject.Initialize(Boolean getObject)
   at System.Management.ManagementBaseObject.get_Properties()
   at System.Management.ManagementBaseObject.GetPropertyValue(String propertyName)
   at Microsoft.Dynamics.Framework.Deployment.Reports.SrsWmi.get_ConfigPath()
   at Microsoft.Dynamics.Framework.Deployment.Reports.ReportLibraryDeployer.DeployBusinessLogicAssemblies(IEnumerable`1 businessLogicAssemblies, DeploymentLogger logger)
   at Microsoft.Dynamics.Framework.Deployment.Reports.ReportLibraryDeployer.Deploy(IEnumerable`1 reportLibrariesToDeploy, IEnumerable`1 transitiveReferenceClosure, IEnumerable`1 cultures, DeploymentLogger logger, Func`2 connectionStringModifier)”
 
You just need to disable the UAC (User Account Control), or to run the Deployment tool with right-click “Run as administrator”. As it says in the Dynamics AX installation guide.
 
Duh…
Posted in Dynamics AX 2009 | Comments Off on Dynamics Ax 2009 SSRS report deployment under Server 2008

AP Posting fails because of security setup in Dynamics Ax 4

Good afternoon

During an AX implementation, I’ve noticed that when doing security setup of user groups and permissions, it is important to have the ‘Tables’ node (in AP for example) set to full control for anyone doing AP postings. Starting from there, you can deny access to individual tables belonging to AP, but the parent ‘Tables’ node must be enabled.

It would also seem that the ‘Tables’ node is subtractive, for example, add the following group (see screenshot) to a user of the ‘Admin’ group (other than the ‘Admin’ user itself) and that user will no longer be able to post Packing Slips and Invoices in AP.

APlessT

A group with everything set to full control except the ‘Tables’ node in AP will effectively deny any AP posting to the user. This has been tested in AX 4 sp1 and sp2. I have no logical explanation for the behavior, but I’ve deduced that any security setup should enable the top nodes first and then remove access to the underlying tables as needed.

This article on the Microsoft KB may be related, though I definitely was using SP2 so:

Also note that temporary tables do not show up on the security tree and are handled by that root ‘Tables’ node only. So it’s a good idea to enable the root node anyways.

Keywords: security, tables, posting
Posted in Dynamics Ax 4.0x | Comments Off on AP Posting fails because of security setup in Dynamics Ax 4

How to temporarily suppress infolog messages in Dynamics Ax (deux)

 
Good afternoon,
 
My previous post on the topic was flawed. Here’s a better solution when you want a section of code not to report to the infolog, but still want previous messages to be shown at the end of execution.
 
public static void suppressInfolog(Args _args)
{
    int i;
    ;
 
    info("A");
    i = infolog.line();
 
    info("B"); //Section of code that will not get reported to the infolog
 
    if (infolog.line() > i)
        infolog.cut(i+1, infolog.line());
    info("C");
}
 
Only "A" and "C" will be displayed, "B" will have been suppressed.
 
Keywords: X++, infolog
Posted in Dynamics Ax 4.0x | Comments Off on How to temporarily suppress infolog messages in Dynamics Ax (deux)

Exception::Break in X++ while loop

 
Good morning
 
I noticed something interesting yesterday. When breaking execution while running a loop (by pressing ctrl-break) an Exception::Break is thrown if ‘Yes’ is clicked on the resulting break prompt. Sometimes even if the exception is caught, the execution stops, other times it will continue with no apparent reason. Here’s the example:
 
public static void whileBreak(Args _args)
{
    int i = 1;
    #define.dosomething(i++; i–;)
    ;
    while (i < 1000000)
    {
        try
        {
            i++;
            #dosomething
            sleep(50);
            #dosomething
        }
        catch (Exception::Break)
        {
            info("Break caught.");
        }
    }
}
 
If we want to be sure the execution will stop, we need to add another ‘throw’ inside the ‘catch’ statement. Also note that adding any breakpoint seem to change the behavior of the try-catch.
 
Posted in Dynamics Ax 4.0x | Comments Off on Exception::Break in X++ while loop