Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error registering ILMerged assembly with input parameters of type EntityReference

(0) ShareShare
ReportReport
Posted on by 2,116

Hello,

I'm trying to register an Action with InArguments of type EntityReference. The only change is that the assembly is ILMerged and references to other assemblies.  With InArgument of type string, the assembly is registered successfully but same for InArgument of type EntityReference, it throws below error.

Non-ILMerged assembly with InArgument of type EntityReference workes fine. Please suggest if I'm missing anything. Thanks!

Error:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The type InArgument`1 of the property OpportunityRecord is not supported.
Detail: <OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
<ErrorCode>-2147200995</ErrorCode>
<ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>The type InArgument`1 of the property OpportunityRecord is not supported. </Message>
<Timestamp>2018-01-24T05:19:38.711107Z</Timestamp>
<InnerFault>
<ErrorCode>-2147200995</ErrorCode>
<ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>The type InArgument`1 of the property OpportunityRecord is not supported. </Message>
<Timestamp>2018-01-24T05:19:38.711107Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</OrganizationServiceFault>

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at Microsoft.Crm.Tools.Libraries.RegistrationHelper.RegisterPlugin(CrmOrganization org, CrmPlugin plugin)
at Microsoft.Crm.Tools.AssemblyRegistration.PluginRegistrationViewModel.btnregisterClick()

InArgument Declaration:

[Input("OpportunityRecord")]
[ReferenceTarget("opportunity")]
public InArgument<EntityReference> OpportunityRecord { get; set; }

[Input("AccountRecord")]
[ReferenceTarget("account")]
public InArgument<EntityReference> AccountRecord { get; set; }

[Input("ContactRecord")]
[ReferenceTarget("contact")]
public InArgument<EntityReference> ContactRecord { get; set; }

[Input("OperationType")]
public InArgument<string> OperationType { get; set; }

*This post is locked for comments

  • Shaun W Harvey Profile Picture
    Shaun W Harvey 240 on at
    RE: Error registering ILMerged assembly with input parameters of type EntityReference

    Yes. The trick is to make sure none of the MS assemblies are CopyLocal = True.

    Those assemblies are going to be in the GAC (or equivalent) of your CRM Server (on premise) or Dataverse.

    Using something like ILRepack definitely makes the job easier.

    We do more ILMerge than we'd like and we use a similar nuget package that makes things a whole lot easier via config.

    I am sure you are all aware but "Dependent Assembly Plugins" is now in public preview for Dataverse/Power Platform

    learn.microsoft.com/.../dependent-assembly-plugins

    It allows you to deploy dependent assemblies (that you would have had to ILMerge before) in a nuget package alongside your plugin.

     

    Microsoft have recognised that people need this sort of functionality and have been working hard on a fully supported way of doing so.

    It is definitely the way forward.

    As ILMerged assemblies are technically not supported.

  • Suggested answer
    CVO Profile Picture
    CVO 77 on at
    RE: Error registering ILMerged assembly with input parameters of type EntityReference

    I just started on a new project where they used ILMerge, and I had this exact same issue.  Couldn't figure out why it was throwing the error.

    Alan - that worked!  You legend.  3 and a half years later!

  • Suggested answer
    Alan Mervitz Profile Picture
    Alan Mervitz 295 on at
    RE: Error registering ILMerged assembly with input parameters of type EntityReference

    I have just come across this same problem and identified the cause and solution.

    The issue is that the EntityReference type is defined in the Microsoft.Xrm.Sdk assembly, and when this assembly is included in the DLLs that are ILMerged, the registration process is thinking the EntityReference type on the InArgument is coming from the merged assembly rather than the intrinsic EntityReference type that CRM is aware of. It is likely using the assembly name as part of the type resolution process and the EntityReference from the merged assembly doesn't match the SDK assembly on the server.

    The fix is to remove the Microsoft.Xrm.Sdk from the merged assembly. In my case, the assembly was getting merged in because the Visual Studio project reference to the Microsoft.Xrm.Sdk assembly was set to CopyLocal = true, and setting it to CopyLocal = false fixed the issue. The change may vary depending on how ILMerge has been configured.

  • Temmy Wahyu Raharjo Profile Picture
    Temmy Wahyu Raharjo 2,914 on at
    RE: Error registering ILMerged assembly with input parameters of type EntityReference

    Hi. Actually I'm not a fan of ILMerge. So for merging multiple assembly into 1 assembly, I prefer using IlRepack. The configuration is pretty easy. Make sure you write all the assemblies, update the csproj for Plugin and make postbuild command using this config:

    <Target Name="AfterBuild">
        <ItemGroup>
          <InputAssemblies Include="$(TargetPath)" />
          <!-- Framework -->
          <InputAssemblies Include="$(TargetDir)Assembly1.dll" />
          <InputAssemblies Include="$(TargetDir)Assembly2.dll" />
          <InputAssemblies Include="$(TargetDir)Assembly3.dll" />
        </ItemGroup>
        <ItemGroup>
          <KeyFile Include="$(ProjectDir)key.snk" />
        </ItemGroup>
        <Exec Command="$(ILRepack) /keyfile:@(KeyFile) /parallel /out:$(TargetPath) /lib:$(TargetDir) @(InputAssemblies -> '%(Identity)', ' ')" />
      </Target>


    Assembly merged using ilrepack is more smaller compare to ilmerge. Please take a note, you must giving the snk file also.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans