So I want to update CoreAssemblies to 9.0.2.45. But since 9.0.42 it depends on System.Text.Json, which has lots of dependencies:
-
.NETFramework 4.6.1
- Microsoft.Bcl.AsyncInterfaces (>= 6.0.0)su
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.4)
- System.Numerics.Vectors (>= 4.5.0)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- System.Text.Encodings.Web (>= 6.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
- System.ValueTuple (>= 4.5.0).
So now I want to deploy this plugin, that depends on latest CoreAssemblies. I have CRM 9.1 On-Prem May 2022 Update: 9.1.0010.0102. I try out some action and get some error from my plugin (that is not actually related to those dependencies but is related issue)
>System.MissingMethodException: Method not found: 'Boolean Microsoft.Xrm.Sdk.ParameterCollection.TryGetValue(System.String, !!0 ByRef)'.
> at DEAC.CRM.CRM.Main.Plugin.EmailTicketCreate.OnPreCreate(IServiceProvider serviceProvider)
> at DEAC.CRM.Plugin.BasePlugin.Execute(IServiceProvider serviceProvider): Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #C7310F1D
Alright, the relevant line:
if (localContext.PluginExecutionContext.ParentContext.SharedVariables.TryGetValue("sssUserId", out object sssUserIdObject)) {
Hmm, let's see how "C:\Program Files\Dynamics 365\CRMWeb\bin\Microsoft.Xrm.Sdk.dll" compares with what NuGet gave me:
- CRM Server: [assembly: AssemblyVersion("9.0.0.0") [assembly: AssemblyFileVersion("9.0.46.7901")
- NuGet: [assembly: AssemblyVersion("9.0.0.0") [assembly: AssemblyFileVersion("9.2.47.9489") - So nuget is newer
Yeah, Server version doesn't have TryGetValue. Except it was always there, pre-v9.1
I don't know when that method disappeared, it was there pre-9.1 and is even documented: ParameterCollection.TryGetValue<T>(String, T) Method (Microsoft.Xrm.Sdk) | Microsoft Docs - however the question is more about how can I use the latest CoreAssemblies with baggage of dependencies? I don't see System.Text.Json.dll or any other of those dependencies in C:\Program Files\Dynamics 365\CRMWeb\bin and I don't see them referenced in in C:\Program Files\Dynamics 365\CRMWeb\bin\Microsoft.Xrm.Sdk.dll:
Thus I don't even think that I'll be able to do without ILMerging those dependencies.
Does Microsoft really pushes us to use a tool they officially do not support? (ILMerge). Using these nuget packages is something microsoft officially recommends: Choose your development style for Dynamics 365 Customer Engagement (Developer Guide for Dynamics 365 Customer Engagement (on-premises)) | Microsoft Docs and a quote directly from there:
You should use the latest version of the SDK assemblies to create your plug-ins, custom workflow activities, or XAML workflows. Starting with version 9.x, you should use .NET Framework version 4.6.2.
On the one side, I am broken without using ILMerge and I am screwed using ILMerge. So I now instruct my build to ILMerge Microsoft.Xrm.Sdk with the newly added dependency System.Text.Json and I get:
Unresolved assembly reference not allowed: System.Text.Json.
No problem, we have a solution for that. Except it doesn't work.
What am I doing utterly wrong?
P.S. I also see that there is a transition from Microsoft.Xrm.CoreAssemblies to Microsoft.PowerPlatform.Dataverse.Client as written in Transition client applications to Dataverse ServiceClient - Power Apps | Microsoft Docs however it does not apply to on-prem, quoting: "On-premise applications - this article is not for you, yet"