Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

"Unable to load plug-in assembly" when registering plugins in CRM

Posted on by 210

I've got a rather complex MS CRM plugin project which consists of a LOT of smaller DLLs (including some external references not natively available in CRM).

I usually combine all those DLLs into one using ILmerge. However, recently, this tool has become a hassle - it's slow and can lock up. As such, I wanted to move away from ILmerge and try something else. The first thing I've tried is ILrepack.

This works, and I can create a new DLL. Attempting to load the packaged DLL into the Plugin Registration Tool WORKS - the tools recognizes the package and shows the plugin classes inside.
The problem arises when I actually try to register the plugin. In this case, the operation fails, and I get the following error:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unable to load plug-in assembly.
Detail: <OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
  <ActivityId>016ed764-1a13-4d0f-b9cd-a513efa225cd</ActivityId>
  <ErrorCode>-2147204719</ErrorCode>
  <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
  <Message>Unable to load plug-in assembly.</Message>
  <Timestamp>2017-06-18T18:13:13.4100645Z</Timestamp>
  <ExceptionSource i:nil="true" />
  <InnerFault>
    <ActivityId>016ed764-1a13-4d0f-b9cd-a513efa225cd</ActivityId>
    <ErrorCode>-2147204719</ErrorCode>
    <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
    <Message>Unable to load plug-in assembly.</Message>
    <Timestamp>2017-06-18T18:13:13.4100645Z</Timestamp>
    <ExceptionSource i:nil="true" />
    <InnerFault i:nil="true" />
    <OriginalException i:nil="true" />
    <TraceText i:nil="true" />
  </InnerFault>
  <OriginalException i:nil="true" />
  <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.UpdateAssembly(CrmOrganization org, String pathToAssembly, CrmPluginAssembly assembly, PluginType[] type)
   at Microsoft.Crm.Tools.AssemblyRegistration.PluginRegistrationViewModel.btnregisterClick()

Obviously, this error comes from CRM itself. However, I don't know what to do now. I suspect it's some kind of missing dependency of some sort. However, I was unable to pinpoint the issue using Fusion Logs, and I'm drawing a blank.

What can I do to debug this problem?

*This post is locked for comments

  • Suggested answer
    Jan Kostejn Profile Picture
    Jan Kostejn 55 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    Hi @MateuszBender,

    just runned into the same issue this morning. I've invested about two hours into the research and what I've find won't solve thi, but it'll definitely move us forward!

    Since we use the new .csproj format, we can't use ILMerge and we need to use ILRepack.

    As you mentioned - it only happens with specific assemblies (dlls). For example it's "Microsoft.IdentityModel.Clients.ActiveDirectory.dll" in my case. So I tried to merge different assemblies and register them into CDS (Dynamics v9.1). The assemblies that went through and the ones that haven't were both inspected through ILSpy and maybe I found what's wrong.

    If the assemblies have resources, registration fails. If they have no resources, it goes through.

    8308.no.PNG

    8308.no.PNG

    I'm not sure about how does ILRepack work with resources, but I'll look into it. Some other ideas?

  • MateuszBender Profile Picture
    MateuszBender 210 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    [quote user="Prashnat Verma"]

    Hi,

    I am too facing the same issue with dynamics 365 on-premise. My scenario is even simpler in my dev env. I amtrying to register the plugin & i am popped out with the same error.

    How did you rectify it ?

    Thanks

    Prashant Verma

    [/quote]

    Are you having an issue with an ILmerge'd DLL? From your question it seems you have issues JUST registering a stand-alone DLL. If said DLL is using any external references (XRM libraries excluded) then you're going to get that error; this is why you need to merge any external libraries with your own code using ILmerge.

  • Prashnat Verma Profile Picture
    Prashnat Verma 287 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    Hi,

    I am too facing the same issue with dynamics 365 on-premise. My scenario is even simpler in my dev env. I amtrying to register the plugin & i am popped out with the same error.

    How did you rectify it ?

    Thanks

    Prashant Verma

  • Verified answer
    MateuszBender Profile Picture
    MateuszBender 210 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    Unfortunately I was not able to use ILrepack and had to settle for using ILmerge in the end. I've also noticed that ILmerge will lock up if some of the DLLs you're trying to merge have references to different versions of an external DLL.

    M. Felicia:

    I assume you're having similar issues with ILrepack. If you're "just" getting the same error from CRM, then I'm afraid you should create a new topic and describe your situation as best you can, as each case related to this error can be different.

  • glow_inthe_dark Profile Picture
    glow_inthe_dark 60 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    Hi MateuszBender

    same thing happen to me. Have you find way to overcome this issue?

  • MateuszBender Profile Picture
    MateuszBender 210 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    Yeah, but the merged DLL SEEMS fine. The Plugin Registration Tool can load it correctly and can correctly read the plugin classes. I can also open the DLL in Visual Studio and see the various classes and namespaces inside. It's CRM itself which throws an error during registration. Again - some details related to the error would be welcome - why exactly is it failing?

    I'd need to know SOMETHING about why it's failing before I go ask a question on the ILrepack GitHub - especially since it's unlikely people there will have access to or knowledge of MS CRM. I also suspect that knowing why CRM is failing to load the plugin will let me correct the issue as well.

  • Hari Narayanan Profile Picture
    Hari Narayanan 589 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    May be its good to open a discussion in the ILrepack github , since this is more of a IL re-pack dependent question. I've not used ILrepack so i'm out of option.

  • MateuszBender Profile Picture
    MateuszBender 210 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    The problem arises in a development environment - as such, I'm doing things as the system administrator and subsequently I have all the required permissions. So it's not a permissions issue.

    The CRM in question is the latest version of on-premise CRM 2016. I don't think it's version dependant, however.

    I've also found out the problem seems to stem from the difference in how ILrepack works (as opposed to ILmerge). Specifically, something happens when I attempt to add Microsoft.Practices.Unity.DLL as part of final assembly. If I skip this DLL, then plugin registration will work fine (obviously the code will throw an error later during plugin execution, as it'll be missing a required DLL). Like I wrote in the original post - the project consists of a number of smaller DLLs - some of which are mine and some are external (the Practices.Unity package being one of those external things).

    It might be that ILmerge adds additional assemblies as part its merge operation and ILrepack does not - but since I'd like to move away from ILmerge in favour of ILrepack, I'd still like to know why the registration is failing beyond that generic error message...

  • Hari Narayanan Profile Picture
    Hari Narayanan 589 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    your question implies that you tried to combine the assemblies and register the same, which denotes that you were trying to update an existing DLL.

    Lets try solving the problem. can try the steps mentioned in the below url to check if any missing permissions

    Here

    Also can you provide details like CRM version and Online or on premise etc

    [View:https://community.dynamics.com/crm/f/117/t/145463:750:50]

  • MateuszBender Profile Picture
    MateuszBender 210 on at
    RE: "Unable to load plug-in assembly" when registering plugins in CRM

    That's definitely not it.

    I'm trying to register a new assembly. I never stated I was trying to update an existing DLL.

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans