I'm trying to debug plugin assembly that been merged via ILRepack, but Plugin Registration tool's Replay Plug-in Execution throws an error related to 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.
Merging command looks like this:
<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>
Code execution works fine in Dynamics 365 CE (online), only Plugin replay is throwing an error.
I tried:
- Debug non-merged assembly, that did not help.
- Debug non-signed merged assembly, that did not help.
- To not use ILRepack, but that made it even worse.
- To use different merge tools like
ILRepect.Lib.MSBuild.Task
orILRepack.MSBuild.Task
but those have same effect.
Here's some code that throws actual error:
var data = System.Text.Json.JsonSerializer.Serialize(object);
Version of System.Text.Json
is 6.0.5