Getting Error: Value cannot be null. Parameter name: detail

Feb 22, 2013 at 12:44 AM
Am using RU 12.

After connecting using Active Directory.

I tried executing the following. Any suggestions why the 'Value cannot be null. Paramter name: detail" error?

Also, when I try executing a subsequent time, I get the following error:

The communication object, System.ServiceModel.ChannelFactory`1[Microsoft.Xrm.Sdk.IOrganizationService], cannot be used for communication because it has been Aborted.

<fetch mapping="logical" version="1.0">
<entity name="bkm_caseline">
<attribute name="bkm_caselineid" />
<attribute name="bkm_caselinesid" />
<attribute name="bkm_installedbase" />
<attribute name="bkm_part" />
<attribute name="bkm_partbeingreplaced" />
<attribute name="bkm_serialnumber" />
<attribute name="bkm_serialnumberbeingreplaced" />
<attribute name="bkm_warrantyofnewitem" />
</entity>
</fetch>
Feb 22, 2013 at 11:42 AM
Edited Feb 22, 2013 at 11:44 AM
I was able to application to work if i run directly from the source code.
One thing I've noticed is that it doesn't seem to like link-entity lookup elements.

I get this error:

Unable to cast object of type 'System.String' to type 'Microsoft.Xrm.Sdk.EntityReference'.

Here is the query I built from advanced find.

It appears not to work when linked-entites reference lookups attributes.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="bkm_caseline">
<attribute name="bkm_name" />
<attribute name="createdon" />
<attribute name="bkm_totalprice" />
<attribute name="bkm_quantity" />
<attribute name="bkm_priceunit" />
<attribute name="bkm_part" />
<attribute name="bkm_linetype" />
<attribute name="bkm_hours" />
<attribute name="bkm_caselineid" />
<order attribute="bkm_linetype" descending="false" />
<order attribute="bkm_part" descending="false" />
<link-entity name="product" from="productid" to="bkm_part" visible="false" link-type="outer" alias="a_04a5a20e857ee111a56c000c29600a1a">
  <attribute name="productnumber" />
  <attribute name="name" />
  <attribute name="pricelevelid" />
  <attribute name="bkm_addproducttoinstalledbasewhenposted" />
</link-entity>
<link-entity name="bkm_installedbase" from="bkm_installedbaseid" to="bkm_installedbase" visible="false" link-type="outer" alias="a_19cf85760655e211b8ae00059a3c7800">
  <attribute name="bkm_name" />
  <attribute name="bkm_product" />
</link-entity>
</entity>
</fetch>

However, this works (note I've removed the lookups)

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="bkm_caseline">
<attribute name="bkm_name" />
<attribute name="createdon" />
<attribute name="bkm_totalprice" />
<attribute name="bkm_quantity" />
<attribute name="bkm_priceunit" />
<attribute name="bkm_part" />
<attribute name="bkm_linetype" />
<attribute name="bkm_hours" />
<attribute name="bkm_caselineid" />
<order attribute="bkm_linetype" descending="false" />
<order attribute="bkm_part" descending="false" />
<link-entity name="product" from="productid" to="bkm_part" visible="false" link-type="outer" alias="a_04a5a20e857ee111a56c000c29600a1a">
  <attribute name="productnumber" />
  <attribute name="name" />
</link-entity>
<link-entity name="bkm_installedbase" from="bkm_installedbaseid" to="bkm_installedbase" visible="false" link-type="outer" alias="a_19cf85760655e211b8ae00059a3c7800">
  <attribute name="bkm_name" />
</link-entity>
</entity>
</fetch>
Feb 22, 2013 at 12:44 PM
Below is the fix to making lookup attributes appear from the linked entities.

FROM FetchXMLForm.cs - line 95
            return getValuefromAttribute(((Microsoft.Xrm.Sdk.AliasedValue)p).Value.ToString());
TO
            return getValuefromAttribute(((Microsoft.Xrm.Sdk.AliasedValue)p).Value);

Cheers!