Wednesday, April 29, 2015

Error when Deploying SSRS from VS 2010- Solved - Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)

Error 1 The "DeployToReportsServerTask" task failed unexpectedly.
System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at Microsoft.Dynamics.Framework.Deployment.Reports.DomainBound.PrepareTask(AppDomain tempAppDomain)
   at Microsoft.Dynamics.Framework.Deployment.Reports.DeployToReportsServerTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() C:\Program Files (x86)\MSBuild\Microsoft\DynamicsTools\Microsoft.Dynamics.Framework.Design.Reporting.Modeling.targets 466 6 AccountantShortTermSolvency

Solution:

Please GOTO Computer properties and follow the below steps



Monday, January 5, 2015

AX 2012: Merge ledger and financial dimensions using X++ code

Hi Friends,
In this post let us see how to use out of the box available X++ API which can be used to merge ledger and financial dimensions.  The below code works well with AX2012/ AX2012 R2/ AX2012 R3 versions of Microsoft Dynamics AX. This is useful in scenarios when we need to create journal from code and need to merge the dimensions in order to get the correct offset account values.

So to keep it simple, let consider the below scenario:
Customer "2014" in the system is having the below financial dimensions defined on it:



Now let's create a standard AX general journal and on it's journal line, let's select account type as customer, account as customer account "2014" , offset account as Ledger  and then from lookup select ledger account "110101", as shown below:



As soon as you select the ledger account, you will notice that system merges the ledger dimension and the financial dimension and create the complete offset account dimension value with the display value as shown below:



To do this from code, use API serviceCreateLedgerDimension() available DimensionDefaultingService class, it is advisable to merge the dimensions whenever you create journal from X++ code, to make sure the resulting voucher entries are against correct and complete accounts.

static void Job1(Args _args)
{
    RecId   customerDefaultDimension = CustTable::find("2014").DefaultDimension;
    RecId   ledgerDimension = AxdDimensionUtil::getMultiTypeAccountId(enumNum(LedgerJournalACType),LedgerJournalACType::Ledger,[110101,110101]);

    info(DimensionAttributeValueCombination::getDisplayValue(DimensionDefaultingService::serviceCreateLedgerDimension(ledgerDimension,customerDefaultDimension)));
}



Line 1 --> gets the RecID which relates to the financial dimension defined on the customer.

Line 2 --> Get the RecID which related to the ledger account 110101.

Line 3 --> Is actually combining the logic to convert the recID into the display value and also to merge the dimensions.

DimensionDefaultingService::serviceCreateLedgerDimension() --> is the function which merges the dimensions. It takes the ledger dimensions and then the financial dimension which needs to be merged and returns the recID of the merged dimension.
DimensionAttributeValueCombination::getDisplayValue() this function returns the display value of the recID which is passed to it. I have used it here to demonstration purpose only. 

There are many other useful API's existing in this class which can be very helpful in developing customizations which require to use financial and ledger dimensions.