See the question and my original answer on StackOverflow

The default TLB importer - or equivalent Visual Studio UI operations - that creates the Interop.UIAutomationClient assembly uses the "[out, retval]" signature layout instead of using Preservesig attribute (more on this here http://blogs.msdn.com/b/adam_nathan/archive/2003/04/30/56646.aspx).

So for example, here it declares IUIAutomationGridPattern like this (simplified version):

[Guid("414C3CDC-856B-4F5B-8538-3131C6302550"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IUIAutomationGridPattern
{
    UIAutomationClient.IUIAutomationElement GetItem(int row, int column);
    ...
}

instead of this:

[Guid("414C3CDC-856B-4F5B-8538-3131C6302550")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IUIAutomationGridPattern
{
    [PreserveSig]
    int GetItem(int row, int column, out UIAutomationClient.IUIAutomationElement element);
    ...
}

Although both are valid, the latter one is better if you want to carefully handle exceptions. The first one does some magic wich unfortunately transforms what's interesting here in something less interesting. So, if you use the PreserveSig version, you can replace the code in GridItem.cs like this:

    public AutomationElement GetItem(int row, int column)
    {
        try
        {
            UIAutomationClient.IUIAutomationElement element;
            int hr = _pattern.GetItem(row, column, out element);
            if (hr != 0)
                throw Marshal.GetExceptionForHR(hr); // note this uses COM's EXCEPINFO if any

            return AutomationElement.Wrap(element).GetUpdatedCache(CacheRequest.Current);
        }
        catch (System.Runtime.InteropServices.COMException e)
        {
            Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
        }
    }

And you should now see original exceptions.

So to fix the code, you'll have to redefine all interfaces involved, manually (or there is here http://clrinterop.codeplex.com/releases/view/17579 a newer tlbimp that can create signatures with PreserveSig - not tested). You will have to change the UIAComWrapper code also. Quite a lot of work ahead.