c# - Dynamics CRM custom workflow activity and GAC reference version -
i experiencing error in crm workflows run custom activities reference common assembly gac, different versions. situation following:
assembly , assembly b (both custom activities) reference assembly c contain base class (inheriting codeactivity) , b crmsvcutil generated class. assembly c exists in gac multiple versions. now, created new attribute in crm, regenerated types crmsvcutil, updated version of assembly c 1.0.0.3 , put gac, rebuilt assembly b (which uses new attribute) , updated using plugin registration tool.
the error shows in workflows reference both assembly , b error message "assembly.type" cannot converted "assembly.type". in base class (assembly c) set assembly property able work strong types:
iorganizationservicefactory servicefactory = executioncontext.getextension<iorganizationservicefactory>(); var type = type.gettype("microsoft.crm.workflow.synchronousruntime.workflowcontext, microsoft.crm.workflow, version=5.0.0.0"); type.getproperty("proxytypesassembly").setvalue(servicefactory, typeof(xrmservicecontext).assembly, null); iorganizationservice service = servicefactory.createorganizationservice(context.userid);
it seems me crm caches base class proxy types , tries use on assembly b, despite references new version of c. if create workflow activity assembly b, works fine, if assembly referenced in same wf , before b.
this problem in production environment , trying find fix it. know can update assembly use new version of c , did in test environment, since there lot of more assemblies two, many tests must performed.
- can somehow point updated assembly b older version of c(and use indexer attribute name new attribute)? tried reverting assembly version of c 1.0.0.2, compiling again b, error assembly cannot updated in plugin registration tool.
- can explain how , assembly keep version of referenced assembly. how work in .net in general?
the strangest thing tried copy base class , types class assembly b (in it's own namespace), remove reference assembly c, updated in plugin registry tool , got same error, time "assemblyc.type" cannot converted "assemblyb.type". don't understand how when removed reference assembly c.
any suggestion appreciated, in advance.
edit: have found out relates dialogs. works fine workflows. ring bell?
several ideas.
for me looks early-bound assemblies create more problems, helps solve. , main issue here lack of transparency. done behind scene implicitly. user have no control on this.
i've noticed crm automatically resolves early-bound assemblies within 1 appdomain
. means, if have 2 assemblies uses different version of same early-bound assembly, assembly loaded first, drag early-bound assembly appdomain
, further plugins, cwa
s forced use loaded early-bound assembly.
how fix? if these custom workflow activities used in different workflows — try register assemblies in isolation. haven't tried scenario, if these workflows won't share same appdomain
early-bound types not messed up.
another approach: try bundle early-bound assemblies cwa
. result abnormally huge files, solve problem (and can remove unused definitions early-bound assembly make slimmer).
one more idea: check link. here in xrmtoolbox
we're trying find solution problem. basically, there way manually cast late-bound assemblies selected early-bound.
xrmtoolbox
contains proposal, allows specify directly assembly use.
Comments
Post a Comment