How can the size (MB) of a workflow assembly be reduced?

An assembly with 4 custom workflow activities is 2.5 MB with the class that crmcsvutil.exe generates from CRM; the same assembly is 18 KB when the generated class is not included in the project!

Plugin registration often fails after timing out, so I would really like to reduce the size of the assembly.

I have tried placing the generated class in a separate assembly and referencing it, and placing the assembly in the GAC, but get an error.

This is when the assembly is registered in the sandbox (which I really prefer):

Assembly 'Tinkerbell.Workflows, Version=2.0.3.4, Culture=neutral, PublicKeyToken=692195edcbe6b163' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself.  In order to access security critical code, this assembly must be fully trusted.'

This is when the assembly is registered outside of the sandbox:

'Object of type 'Microsoft.Xrm.Sdk.Entity' cannot be converted to type 'BusinessUnit'.'

What are the options here?
I am unwilling to give up early bound classes.

有帮助吗?

解决方案

You can generate only the early bound entities you need, with this utility Filtering generated entities with CrmSvcUtil.

You just need to specify a xml with the desired entities:

<filter>
  <entities>
    <entity>systemuser</entity>
    <entity>team</entity>
    <entity>role</entity>
    <entity>businessunit</entity>
  </entities>
</filter> 

其他提示

You could manually edit the class file that CRM generates to strip out all but the entities that you need but that would be a bit of a pain and would need to be redone if you ever regenerated the CRM class file.

Is there a reason why you don't want to abandon early classes? Late bound does have some advantages and is slightly quicker. If you want to keep the early bound feel then you can write your own classes and then write mapping functions that translate from your classes to entities.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top