Search code examples
c#visual-studiovisual-studio-2015microsoft-dynamicsilmerge

ILMerge with Microsoft.Servicebus.dll for CRM plugin


I am trying to use ILMerge to merge the Microsoft.Servicebus.dll in to my CRM plugin dll. For some reason i keep getting the below error when trying to build my project;

Unresolved assembly reference not allowed: Microsoft.Azure.Services.AppAuthentication.

The versions I am using for each dll are listed below in the screenshot. I have no idea why this is happening but it works if I change the version of the servicebus dll down to 4.1.6. (If I do that, i get another error when actually running the CRM plugin code, so I want to use 4.1.7).

enter image description here


Solution

  • For anyones info, in the end I didn't merge the servicebus dll in with the plugin code. I called an Azure Function (via a Webhook using WebClient). The Azure function had the servicebus dll and code instead of my plugin. All the plugin ended up doing was calling this function.

            public static void FileCopy(string source, string dest, string webhookurl)
        {
            using (var client = new WebClient { Headers = { [HttpRequestHeader.ContentType] = "application/json" } })
            {
                var paramRecord = new Parameters(source, dest);
    
                var serializer = new DataContractJsonSerializer(typeof (Parameters));
                var memoryStream = new MemoryStream();
                serializer.WriteObject(memoryStream, paramRecord);
    
                // todo handle the removal of escaped strings better
                var jsonObject = Encoding.Default.GetString(memoryStream.ToArray()).Replace(@"\", "");
    
                string response = client.UploadString(webhookurl, jsonObject);
            }
        }