调试经ILRepack合并的Dynamics 365插件遇运行时不稳定错误
Dynamics 365 CE插件合并后重放执行报错:Operation could destabilize the runtime
我用ILRepack合并插件程序集后,在Plugin Registration工具的Replay Plug-in Execution功能中遇到与System.Text.Json相关的错误,错误信息如下:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Operation could destabilize the runtime.
合并时使用的MSBuild目标配置如下:
<Target Name="ILRepack" AfterTargets="Build"> <Message Text="ILRepack is running..." /> <ItemGroup> <ILRepackPackage Include="..\packages\ILRepack.2.0.18\tools\ILRepack.exe" /> </ItemGroup> <Error Condition="!Exists(@(ILRepackPackage->'%(FullPath)'))" Text="You are trying to use the ILRepack package, but it is not installed or at the correct location." /> <Exec Command="@(ILRepackPackage->'%(FullPath)') /out:$(OutputPath)Merged\$(AssemblyName).dll $(OutputPath)$(AssemblyName).dll <...AND ALL OTHER ASSEMBLIES> /parallel /wildcards /target:library /keyfile:NPDKey.snk" /> </Target>
插件在Dynamics 365 CE线上环境运行完全正常,唯独在插件重放执行时触发该错误。
我已经尝试过以下方法,但都没有解决问题:
- 调试未合并的程序集
- 调试未签名的合并程序集
- 不使用ILRepack(问题反而更严重)
- 使用ILRepack.Lib.MSBuild.Task或ILRepack.MSBuild.Task等其他合并工具(结果和用ILRepack一样)
触发错误的代码行是:
var data = System.Text.Json.JsonSerializer.Serialize(@object);
当前使用的System.Text.Json版本为6.0.5。
内容的提问来源于stack exchange,提问作者Paulius
相关产品推荐
相关产品推荐

