Push data to servicebus when a contact is created - CRM Online RRS feed

  • Question

  • We are trying to push data to Azure Service Bus Queue when a contact is created in "Dynamics CRM Online".

    We have implemented it using a plugin by registering it with Plugin Registration Tool. But somehow its throwing an error while saving the contact. Here is the code which we have implemented in plugin:

    public void Execute(IServiceProvider serviceProvider)
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                Entity entity = (Entity)context.InputParameters["Target"];
                if (entity.LogicalName.Equals("account"))
                    QueueDescription qd = new QueueDescription("testQ");
                    qd.MaxSizeInMegabytes = 5120;
                    qd.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);
                    string connectionString =
                    var namespaceManager =
                    if (!namespaceManager.QueueExists("testQ"))
                    QueueClient Client =
                        QueueClient.CreateFromConnectionString(connectionString, "testQ");
                    BrokeredMessage message = new BrokeredMessage(entity);
                    message.Properties["FirstName"] = "ABC";
                    message.Properties["LastName"] = "Z";
            catch (Exception e)

    Error message:

    Business Process Error

    Unexpected exception from plug-in (Execute): Microsoft.Crm.Sdk.Samples.Account: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ServiceBus, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

    Friday, November 1, 2013 12:14 PM