ServiceStack.text not Load file System.Memory

1.6k Views Asked by At

Good morning, we are developing a dll that uses ServiceStack.Text.dll (5.4). The installation in the project was done via nuget. Locally the application works fine while on a server machine it has problems. The following error occurs when loaded into memory and run on in Windows Server 2012 r2 standard . We have the following error:

System.TypeInitializationException: The type initializer for 'ServiceStack.Text.TypeSerializer' threw an exception. ---> System.TypeInitializationException: The type initializer for 'ServiceStack.Text.JsConfig' threw an exception. ---> System.IO .FileNotFoundException: Could not load file or assembly 'System.Memory, Version = 4.0.1.0, Culture = neutral, PublicKeyToken = cc7b13ffcd2ddd51' or one of its dependencies.

The system cannot find the file specified. But in our build folder the indicated system.memory is available and also its dependencies.

Do you have any suggestions?

1

There are 1 best solutions below

6
mythz On

You'll likely need an Assembly Binding in your Web.Config (or App.Config for non Web Apps) to reference the version of System.Memory your project has referenced, something like:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" 
            publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>