System.IO.FileNotFoundException Problem

JerryM 1,116 Reputation points
2021-01-23T08:59:34.667+00:00

Hello,

I am trying to use Roslyn compiler:

        g_ms = new MemoryStream();
        g_result = g_compilation.Emit(g_ms);

But I am getting this very suspicious error:

FileNotFoundException: Could not load file or assembly 'System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Inner exception:
FileNotFoundException: Could not load file or assembly 'System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Can someone help me where is problem ?

many thanks.
J.

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,135 questions
0 comments No comments
{count} votes

Accepted answer
  1. JerryM 1,116 Reputation points
    2021-01-23T09:16:43.85+00:00

    great ! I found the answer. in app.config it is necessary to redirect newer version to older:

            <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.31.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
    
    0 comments No comments

0 additional answers

Sort by: Most helpful