Uploading plugin assembly to MS CRM Online programmatically

932 views Asked by At

I'm trying to upload new version of plugin assembly containing CRM plugins to MS CRM Online instance by using my custom application, not PluginRegistrationTool.

Approach is really straightforward:

var plugin = new Entity("pluginassembly")
{
    Id = PluginId // correct GUID of the plugin assembly stored in CRM
};

plugin["content"] = Convert.ToBase64String(ReadBinaryFile(filename));

Service.Update(plugin);

The code works fine when I'm testing with CRM on-premises. However, when I point Service to MS CRM online, the result is not successful.

The assembly is uploaded, but when I'm trying to execute step to which it's assigned, CRM fires SecurityException:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #E824CF49Detail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220970</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #E824CF49</Message>
  <Timestamp>2015-06-24T07:57:27.5491666Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

</TraceText>
</OrganizationServiceFault>

I can understand, that CRM Online probably performs additional checks. But I cannot understand what exactly it checks and why assembly uploaded with PluginRegistrationTool passes this checks, and uploaded directly — fails that checks.

Have anyone experienced already issues like this? Maybe someone could help answer without reverse engineering PluginRegistrationTool?

Thanks in advance for any clues.

1

There are 1 answers

0
shytikov On BEST ANSWER

@HenkvanBoeijen's comment gave me a clue, that actually helped.

My plugin uses external libraries, and they are packaged with the main code using ILMerge tool. But. It was an error during merging process. Resulting file was captured by my code BEFORE it was signed by ILMerge. Thus, file itself was OK, but since it's not signed with the strong name, it failed in Isolated mode and was ok in Normal mode.

So the solution was not to hurry up and let ILMerge complete it's job. After that everything worked fine.