locked
Third-party DLL reference with CRM Online RRS feed

  • Question

  • Hi There,

    I'm trying to build a plugin that calls a REST web service elsewhere on the web. To help me make the request to the web service, I'm using the open-source RestSharp library. I had to sign the RestSharp.dll, but other than that, I was able to build everything successfully. However, in CRM Online, the system job created when the plugin runs has the following error:

    System.IO.FileNotFoundException: Could not load file or assembly 'RestSharp, Version=102.0.0.0, Culture=neutral, PublicKeyToken=f951035e27ea705d' or one of its dependencies. The system cannot find the file specified.

    I thought that the RestSharp dll referenced in my plugin would be compiled with my plugin dll - but I guess not. How can you use a third-party assembly in a plugin?

     

    Thanks!

    Andy


    Blog: http://andrewbschultz.com @andrewbschultz
    Friday, December 16, 2011 5:39 PM

Answers

All replies

  • Hello,

    Try to merge your assemblies using following tool - http://www.codeproject.com/KB/dotnet/mergingassemblies.aspx


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter
    Friday, December 16, 2011 5:49 PM
    Moderator
  • Hi Andriy,

     

    Thanks for the reply - I'm trying to use the ILMerge tool to merget the assemblies into one. However, when I do so, and then try to use the Plugin Registration Tool to upload the assembly to CRM Online, there is no longer any recognized plugin inside the assembly anymore. It strips it out for some reason. Has this happened to you?

     

    Thanks!


    Blog: http://andrewbschultz.com @andrewbschultz
    Friday, December 16, 2011 7:09 PM
  • Hello,

    Could you please provide command with which you've merged assemblies?


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter
    Friday, December 16, 2011 7:30 PM
    Moderator
  • Hi Andriy,

     

    Sure -

    ilmerge.exe /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"yammer_updateplugin.snk" /out: bin\release\yammer_update.dll bin\release\RestSharp.dll bin\release\Newtonsoft.dll bin\release\microsoft.xrm.sdk


    Blog: http://andrewbschultz.com @andrewbschultz
    Friday, December 16, 2011 8:39 PM
  • I just realized the RestSharp project was built in 3.5 client profile - that might be part of the problem. I just built my plugin inside the original RestSharp project instead of trying to add RestSharp to my plugin project, and I was able to get the plugin operating in CRM that way. I'll try to use ILMerge again to see if changing the .NET framework fixes the issue.
    Blog: http://andrewbschultz.com @andrewbschultz
    Friday, December 16, 2011 11:14 PM
  • Thanks Andriy. That seemed to be the problem. Once I built RestSharp project in .NET 4.0 and then used ILMerge to combine RestSharp.dll with my plugin dll, I could register the resulting dll. The plugin reg tool detected the plugin in the assembly then.

    I also was missing the target dll in my earlier ILMerge command, which I fixed so it wasn't updating my existing plugin dll:

    ilmerge.exe /targetplatform:v4, "C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"yammer_updatekey.snk" /out:totalplugin.dll bin\release\yammer_update.dll bin\release\RestSharp.dll bin\release\Newtonsoft.json.dll bin\release\microsoft.xrm.sdk.dll


    Blog: http://andrewbschultz.com @andrewbschultz
    Wednesday, December 21, 2011 5:58 PM
  • Actually, I take that back - I can't put the microsoft.xrm.sdk.dll in the new assembly created by ILMerge. If I do, I get an error saying

    Plug-in assembly does not contain the required types or assembly content cannot be updated.

    At first, the ILMerge failed when I removed microsoft.xrm.sdk.dll from the command. I don't know why. After deleting my project assemblies and rebuilding my project, and trying to re-do it a few times, I was able to ILMerge without that assembly, and it registered successfully.


    Blog: http://andrewbschultz.com @andrewbschultz
    Wednesday, December 21, 2011 6:46 PM
  • Hi Andrew,

    I have completed the merge process successfully, but while doing the registration i am unable to plug-in list and getting error message like no plug-in is selected please select at least one. Could you please shed some light on this issue?

     

     


    Thanks, Ankit Shah
    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html
    Saturday, January 21, 2012 12:18 PM
  • Hi Andriy/Andrew,

    Are you able to debug a code with a third-party dll? I am unable to load my dll in CRM environment. Below error is being thrown,

    Could not load file or assembly 'Mydllname' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

     

    Please advise. It's really urgent!


    Thanks, Ankit Shah
    Inkey Solutions, India.
    Microsoft Certified Business Management Solutions Professionals
    http://www.inkeysolutions.com/MicrosoftDynamicsCRM.html
    Tuesday, January 24, 2012 10:16 AM