Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Servicebus DLL in a plugin and ILMerge

Posted on by 300

Hi,

I have used ILMerge to add the Microsoft.Servicebus.dll in to my Dynamics 365 Online plugin so that I can send messages to a bus.

I get the following exception when the code is run;

System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.ServiceBus.AuthorizationFailedException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Microsoft.Xrm.Sdk.KnownProxyTypesProvider.LoadKnownTypes(Assembly assembly)
at Microsoft.Xrm.Sdk.KnownProxyTypesProvider.RegisterAssembly(Assembly assembly)
at Microsoft.Xrm.Sdk.AssemblyBasedKnownProxyTypesProvider.GetNameForType(Type type)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.CheckEntitySubclass(Type entityType)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.CreateQuery[TEntity]()
at Xrm.ServiceContext.get_ContactSet()
at Co_op.Registry.Integration.Plugin.Steps.PopulatePrimary.Process(Registration registration, reg_registration sourceRecord, ServiceContext service)
at Co_op.Registry.Integration.Plugin.Managers.IntegrationManager.CreateRegistrationIndividual(reg_registration sourceRecord, ServiceContext service)
at Co_op.Registry.Integration.Plugin.IntegrationAction.Execute(IServiceProvider serviceProvider)


Both my DLL and the service bus DLL are on the same version and I have tried .net 4.5.2 and 4.6.1.  Does anyone know how to resolve this issue with ILMerge and the servicebus dll?

*This post is locked for comments

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: Servicebus DLL in a plugin and ILMerge

    Hello,

    Please keep in mind that CRM doesn't support ILMerge - see following MSDN blog: blogs.msdn.microsoft.com/.../how-to-reference-assemblies-from-plug-ins

    "8/31/15 This post has been edited to reflect that Dynamics CRM does not support ILMerge.  It isn't blocked, but it isn't supported, as an option for referencing custom assemblies."

    So this might be a potential reason for it to break.

    I think it would be worth to consider David's suggestions.

    Hope this helps,

    Radu

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Servicebus DLL in a plugin and ILMerge

    The original implementation essentially passed the plugin execution context so that you could offload the plugin processing, but there are two more recent options:

    • Sending to the Event Hub (which still sends to context)
    • Sending to a Web Hook (came with CRM v9.0)
  • mluce Profile Picture
    mluce 300 on at
    RE: Servicebus DLL in a plugin and ILMerge

    Hi,

    I'm creating some custom JSON off of an entity Create plugin and then sending to a queue. I was under the impression that the standard bus integration with the Plugin Registration Tool only sends specific format / details?

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Servicebus DLL in a plugin and ILMerge

    I don't know exactly why this is failing, but I expect you're causing a conflict between the servicebus classes in your assembly, and the Microsoft.Servicebus.dll that CRM will use, and this conflict is most likely due to running at different trust levels, which you can't change

    Why are you trying to directly use Microsoft.Servicebus.dll ? Is there something in the CRM and Azure Integration that stops you using that instead ?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans