Skip to content

System.MissingMethodException for JsonDocument.Parse(System.ReadOnlyMemory`1<Char>, System.Text.Json.JsonDocumentOptions) #126401

@Trivedi-Ashish

Description

@Trivedi-Ashish

I have a library which depends on below NuGet packages,

  • System.Text.Json (NuGet version 8.0.5) which in turn depends on System.Memory (NuGet 4.5.5)
  • System.Memory (NuGet version 4.6.3)

The library acts as a plugin to an Application on which I have limited control.
I am supposed to just supply my library (a single DLL) to the application. Application loads my library and all my dependencies either from its own installation path or windows OS location.

I am getting MissingMethodException in my library when it is executed by the application. I am using JsonDocument.Parse method overload which takes in ReadOnlyMemory.

System.MissingMethodException: Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.ReadOnlyMemory`1, System.Text.Json.JsonDocumentOptions)

On investigating the DLLs loaded by the application (using Process Explorer), I found out that application has below DLLs loaded in its memory,

  • System.Text.Json.dll (from NuGet 9.0.9)
  • System.Memory.ni.dll (native DLL corresponding to managed DLL of version NuGet 4.5.5).

This should have worked. But I got MissingMethodException.

Next, I disabled native image load for System.Memory.ni.dll (assuming native assembly may be causing some conflict). On disabling native image load, application loads managed System.Memory.dll (4.5.5) from its own installation path.

 <disableNativeImageLoad>
  <assemblyIdentity name="System.Memory" />
</disableNativeImageLoad>

I even added System.Memory (NuGet version 4.6.3) in the GAC so that my library may load it if it requires during execution (and in fact it gets loaded, so at a time there are two versions of System.Memory.dll loaded into application memory, one 4.5.5 from its own installation path and another 4.6.3 from GAC)

Now, I don't understand why I am still getting MissingMethodException even after both System.Memory NuGet version 4.5.5 and 4.6.3 are loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions