Monday 23 September 2013

CLR / IL Exceptions in Dynamics AX X++

CLR exceptions are due to .Net Business connector.
when AX tried to call something by reflection but the called method threw an exception.

To understand what failed, you should find what was called and what was the exception.

 1. Catch the exception (by catch (Exception::CLRError)).
 2. Get the CLR exception and look into its InnerException property.
AifUtil::getClrErrorMessage()
is usually the easiest way to do that.

 Eg:
 static void RaiseCLRException(Args _args)
 {
     ;
     //Necessary if executed on the AOS  new InteropPermission(InteropKind::ClrInterop).assert();
     try
    {
         //This will cause an exception
         System.Int32::Parse("abc");
    }
    catch(Exception::CLRError)
    {
     AifUtil::getClrErrorMessage(); 
     //Access the last CLR
      Exception info(CLRInterop::getLastException().ToString());
   }
   //Revert CAS back to normal CodeAccessPermission::revertAssert();
 }

Monday 2 September 2013

C# how to get new value from the Gridview update event

C#: GridViewUpdateEventArgs.NewValues Property getting new value from Grid view

Eg:
Write the Selected Row updating event on the Gridview.

protected void SelectedRowUpdating_Clicked(object sender, GridViewUpdateEventArgs e)
  {
      String tempQty = String.Empty;
     // Iterate through the NewValues collection and HTML encode all
     // user-provided values before updating the data source.
     foreach (DictionaryEntry entry in e.NewValues)
    {
          e.NewValues[entry.Key] = Server.HtmlEncode(entry.Value.ToString());
          tempQty = entry.Key.ToString();
          tempQty = entry.Value.ToString();
    }
   AxGridView3.EditIndex = -1; EditDeleteSelectedOrder(tempQty);
 }

Update NuGet package to new MS D365FO version

1. Import the NuGet package files from LCS for that particular version please take the PU version files only. a. Goto LCS-->Asset Libra...